Skip to content

feat!: no service locator, the injector creates and is injected - #353

Open
mofr wants to merge 2 commits into
feat/decorator-namesfrom
feat/no-service-locator
Open

mofr wants to merge 2 commits into
feat/decorator-namesfrom
feat/no-service-locator

Conversation

@mofr

@mofr mofr commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #352.

What

  • winter.application.set_injector and get_injector are gone.
  • winter.messaging.EventDispatcher, winter.ddd.DomainEventDispatcher and the repository implementation of winter.sqlalchemy declare injector: Injector in their @inject constructors and use it to create handlers or call the constructors of repository subclasses. An injector injects itself, a child injector the child, so each gets the injector that created it.
  • DomainEventDispatcher was created by hand, DomainEventDispatcher(); it is DomainEventDispatcher(injector) now, or created by the injector.
  • The tests share the injector of the sample application from tests/injection.py instead of installing it globally in conftest.py; the messaging and ddd tests use injectors of their own.
  • docs/architecture.md: the last deviation from principle 2 is gone.

Why

These three call sites were the last process-global behaviour of Winter: a service locator, in classes that the injector creates anyway.

To be confirmed on the consumer: where it calls set_injector, get_injector or DomainEventDispatcher().

🤖 Generated with Claude Code

winter.messaging's EventDispatcher, winter.ddd's DomainEventDispatcher and
the repositories of winter.sqlalchemy take the injector that creates them
instead of winter.application.get_injector, so set_injector and
get_injector are gone and nothing in Winter is process-global behaviour.
DomainEventDispatcher(injector) creates the handlers with that injector.
The tests share the injector of the sample application from
tests/injection.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mofr
mofr requested a review from andrey-berenda October 27, 2026 16:43
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant