mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-26 03:23:58 +03:00
1ad852d193
* Update index page * Update providers index page * Make a little wording fix on containers index page * Refactor factory provider docs header * Update factory injection docs * Update factory init injections example and picture * Start work on underlying providers * Finish the docs for factory arguments to the underlying providers * Edit providers delegation section * Edit section about specialized factory provider * Edit abstract factory section * Edit FactoryAggregate docs * Add meta keywords and description
48 lines
1.2 KiB
ReStructuredText
48 lines
1.2 KiB
ReStructuredText
.. _providers:
|
|
|
|
Providers
|
|
=========
|
|
|
|
Providers help to assemble the objects. They create objects and inject the dependencies.
|
|
|
|
Each provider is a callable. You call the provider like a function when you need to create an
|
|
object. Provider retrieves the underlying dependencies and inject them into the created object.
|
|
It causes the cascade effect that helps to assemble object graphs.
|
|
|
|
.. code-block:: bash
|
|
|
|
provider1()
|
|
│
|
|
├──> provider2()
|
|
│
|
|
├──> provider3()
|
|
│ │
|
|
│ └──> provider4()
|
|
│
|
|
└──> provider5()
|
|
│
|
|
└──> provider6()
|
|
|
|
Another providers feature is an overriding. Any of the providers can be overridden by another
|
|
provider. When provider is overridden it calls to the overriding provider instead of providing
|
|
the object by its own. This helps in testing. This also helps in overriding API clients with
|
|
stubs for the development or staging environment.
|
|
|
|
Providers module API docs - :py:mod:`dependency_injector.providers`
|
|
|
|
.. toctree::
|
|
:maxdepth: 2
|
|
|
|
factory
|
|
singleton
|
|
callable
|
|
coroutine
|
|
object
|
|
list
|
|
configuration
|
|
selector
|
|
dependency
|
|
overriding
|
|
provided_instance
|
|
custom
|