python-dependency-injector/docs/introduction/structure.rst

52 lines
1.8 KiB
ReStructuredText
Raw Normal View History

Structure of Dependency Injector
--------------------------------
2016-03-31 21:00:48 +03:00
.. meta::
2016-04-23 15:00:06 +03:00
:keywords: Python,DI,Dependency injection,IoC,Inversion of Control
:description: This article describes "Dependency Injector" framework
components and their interaction between each other.
Catalogs, providers and injections are the former
components of the framework.
2016-03-31 21:00:48 +03:00
Current section describes *Dependency Injector* main entities and their
interaction between each other.
.. image:: /images/internals.png
:width: 100%
:align: center
2016-03-31 21:13:28 +03:00
There are 3 main entities: providers, injections and catalogs.
2016-03-31 21:00:48 +03:00
+ All of the entities could be used in composition with each other or
separatelly.
+ Each of the entities could be extended via specialization.
2016-03-31 21:13:28 +03:00
Providers
~~~~~~~~~
Providers are strategies of accesing objects. For example,
:py:class:`dependency_injector.providers.Factory` creates new instance
of provided class every time it is called.
:py:class:`dependency_injector.providers.Singleton` creates provided
instance once and returns it on every next call. Providers could be
injected into each other. Providers could be overridden by another
providers. Base class is -
:py:class:`dependency_injector.providers.Provider`.
Injections
~~~~~~~~~~
Injections are instructions for making dependency injections
(there are several ways how they could be done). Injections are used
mostly by :py:class:`dependency_injector.providers.Factory` and
:py:class:`dependency_injector.providers.Singleton` providers, but
these are not only cases. Base class is -
:py:class:`dependency_injector.injections.Injection`.
Catalogs
~~~~~~~~~
Catalogs are collections of providers. They are used for grouping
of providers by some principles. Base class is -
:py:class:`dependency_injector.catalogs.DeclarativeCatalog`.