Skip to content

Use single registry for all scopes #543

@Tishka17

Description

@Tishka17

Currently, registries are created for each scope. Here’s how it works now:

  • A container looks in its own registry.
  • If nothing is found, it queries the parent.
  • This continues until all parents are checked, and only then an error is thrown.

Proposed approach:

  • Single shared registry for all scopes.
  • The container looks up the factory.
  • If the factory is found, we check its scope.
  • Traverse the parent chain until we find the matching scope.

This way, we reduce the number of dictionary lookups and simplify the stack traversal logic. It probably can be faster.

In the old approach, we couldn’t distinguish between “not found” and “different scope.” Because of that, we couldn’t implement specialization logic for generic factories or provide meaningful error hints.
In the new approach, we immediately know whether a factory exists but is in the wrong scope.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status

Ready

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions