Interfaces (Protocol/ABC)¶
If your code depends on abstractions (Protocols/ABCs), you must tell diwire what concrete class to build.
Two common ways:
concrete_class=...:container.register(Clock, concrete_class=SystemClock)
Decorator:
@container.register(Clock, lifetime=Lifetime.SINGLETON) class SystemClock: ...
Example (runnable)¶
See the runnable script in Patterns (Interface registration section).