mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-03 03:43:29 +03:00
Update docs
This commit is contained in:
parent
82296d9fed
commit
bf00e5c0fa
|
@ -16,6 +16,9 @@ dependency injection pattern in formal, pretty, Pythonic way.
|
||||||
+ Documentation.
|
+ Documentation.
|
||||||
+ Semantic versioning.
|
+ Semantic versioning.
|
||||||
|
|
||||||
|
*Dependency Injector* providers are implemented as C extension types using
|
||||||
|
Cython.
|
||||||
|
|
||||||
Status
|
Status
|
||||||
------
|
------
|
||||||
|
|
||||||
|
|
|
@ -7,5 +7,4 @@ API Documentation
|
||||||
top_level
|
top_level
|
||||||
providers
|
providers
|
||||||
containers
|
containers
|
||||||
utils
|
|
||||||
errors
|
errors
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
``dependency_injector.providers``
|
``dependency_injector.providers``
|
||||||
---------------------------------
|
---------------------------------
|
||||||
|
|
||||||
.. image:: /images/providers/providers_class_diagram.png
|
|
||||||
:width: 100%
|
|
||||||
:align: center
|
|
||||||
|
|
||||||
.. automodule:: dependency_injector.providers
|
.. automodule:: dependency_injector.providers
|
||||||
:members:
|
:members:
|
||||||
:inherited-members:
|
:inherited-members:
|
||||||
|
|
|
@ -17,7 +17,7 @@ Also, for both of these and some other cases, it might be useful to attach
|
||||||
some init / shutdown functionality or something else, that deals with group
|
some init / shutdown functionality or something else, that deals with group
|
||||||
of providers.
|
of providers.
|
||||||
|
|
||||||
Containers module API docs - :py:mod:`dependency_injector.containers`.
|
Containers package API docs - :py:mod:`dependency_injector.containers`.
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 139 KiB |
|
@ -8,7 +8,14 @@ Dependency Injector --- Dependency injection microframework for Python
|
||||||
:description: Dependency Injector is a dependency injection microframework
|
:description: Dependency Injector is a dependency injection microframework
|
||||||
for Python. It was designed to be unified, developer-friendly
|
for Python. It was designed to be unified, developer-friendly
|
||||||
tool that helps to implement dependency injection pattern in
|
tool that helps to implement dependency injection pattern in
|
||||||
formal, pretty, Pythonic way.
|
formal, pretty, Pythonic way. Dependency Injector framework
|
||||||
|
key features are: Easy, smart, pythonic style; Obvious, clear
|
||||||
|
structure; Extensibility and flexibility; High performance;
|
||||||
|
Memory efficiency; Thread safety; Documentation; Semantic
|
||||||
|
versioning; Dependency Injector providers are implemented as
|
||||||
|
C extension types using Cython.
|
||||||
|
|
||||||
|
.. _index:
|
||||||
|
|
||||||
*Dependency Injector* is a dependency injection microframework for Python.
|
*Dependency Injector* is a dependency injection microframework for Python.
|
||||||
It was designed to be unified, developer-friendly tool that helps to implement
|
It was designed to be unified, developer-friendly tool that helps to implement
|
||||||
|
@ -19,11 +26,15 @@ dependency injection pattern in formal, pretty, Pythonic way.
|
||||||
+ Easy, smart, pythonic style.
|
+ Easy, smart, pythonic style.
|
||||||
+ Obvious, clear structure.
|
+ Obvious, clear structure.
|
||||||
+ Extensibility and flexibility.
|
+ Extensibility and flexibility.
|
||||||
|
+ High performance.
|
||||||
+ Memory efficiency.
|
+ Memory efficiency.
|
||||||
+ Thread safety.
|
+ Thread safety.
|
||||||
+ Documentation.
|
+ Documentation.
|
||||||
+ Semantic versioning.
|
+ Semantic versioning.
|
||||||
|
|
||||||
|
*Dependency Injector* providers are implemented as C extension types using
|
||||||
|
Cython.
|
||||||
|
|
||||||
Status
|
Status
|
||||||
------
|
------
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ code for specification of dependencies. Nevertheless, this disadvantage could
|
||||||
be easily avoided by creating inversion of control container (IoC container).
|
be easily avoided by creating inversion of control container (IoC container).
|
||||||
|
|
||||||
Example of creation of several inversion of control containers (IoC containers)
|
Example of creation of several inversion of control containers (IoC containers)
|
||||||
using *Dependency Injector*:
|
using :doc:`Dependency Injector <../index>`:
|
||||||
|
|
||||||
.. literalinclude:: ../../examples/miniapps/engines_cars/example_ioc_containers.py
|
.. literalinclude:: ../../examples/miniapps/engines_cars/example_ioc_containers.py
|
||||||
:language: python
|
:language: python
|
||||||
|
|
|
@ -9,16 +9,40 @@ follows `Semantic versioning`_
|
||||||
|
|
||||||
Development version
|
Development version
|
||||||
-------------------
|
-------------------
|
||||||
- Add ``dependency_injector.injections`` module (C extension).
|
- **Providers**
|
||||||
- Transfer ``dependency_injector.utils`` module to Cython (C extension).
|
|
||||||
- Transfer ``dependency_injector.errors`` module to Cython (C extension).
|
|
||||||
- Remove ``@inject`` decorator.
|
|
||||||
- Add makefile (``clean``, ``test``, ``build``, ``install``, ``uninstall``
|
|
||||||
& ``publish`` commands).
|
|
||||||
- Update repository structure:
|
|
||||||
|
|
||||||
- Sources are moved under ``src``.
|
1. All providers from ``dependency_injector.providers`` package are
|
||||||
- Tests are moved under ``tests/unit``.
|
implemented as C extension types using Cython.
|
||||||
|
2. Add ``BaseSingleton`` super class for all singleton providers.
|
||||||
|
3. Make ``Singleton`` provider not thread-safe. It makes performance of
|
||||||
|
``Singleton`` provider 10x times faster.
|
||||||
|
4. Add ``ThreadSafeSingleton`` provider - thread-safe version of
|
||||||
|
``Singleton`` provider.
|
||||||
|
5. Add ``ThreadLocalSingleton`` provider - ``Singleton`` provider that uses
|
||||||
|
thread-local storage.
|
||||||
|
6. Remove ``provides`` attribute from ``Factory`` and ``Singleton``
|
||||||
|
providers.
|
||||||
|
7. Add ``set_args()`` and ``clear_args()`` methods for ``Callable``,
|
||||||
|
``Factory`` and ``Singleton`` providers.
|
||||||
|
|
||||||
|
- **Containers**
|
||||||
|
|
||||||
|
1. Module ``dependency_injector.containers`` was splitted into submodules
|
||||||
|
without any functional changes.
|
||||||
|
|
||||||
|
- **Utils**
|
||||||
|
|
||||||
|
1. Module ``dependency_injector.utils`` is splitted into
|
||||||
|
``dependency_injector.containers`` and ``dependency_injector.providers``.
|
||||||
|
|
||||||
|
- **Miscellaneous**
|
||||||
|
|
||||||
|
1. Remove ``@inject`` decorator.
|
||||||
|
2. Add makefile (``clean``, ``test``, ``build``, ``install``, ``uninstall``
|
||||||
|
& ``publish`` commands).
|
||||||
|
3. Update repository structure:
|
||||||
|
1. Sources are moved under ``src/`` folder.
|
||||||
|
2. Tests are moved under ``tests/unit/`` folder.
|
||||||
|
|
||||||
.. - No features.
|
.. - No features.
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,12 @@ framework can be installed from PyPi_:
|
||||||
pip install dependency_injector
|
pip install dependency_injector
|
||||||
|
|
||||||
# Installing particular version:
|
# Installing particular version:
|
||||||
pip install dependency_injector==2.0.0
|
pip install dependency-injector==3.0.0
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
Some components of *Dependency Injector* are implemented as C extension types.
|
||||||
|
*Dependency Injector* is distributed as an archive with a source code, so
|
||||||
|
C compiler and Python header files are required for the installation.
|
||||||
|
|
||||||
Sources can be cloned from GitHub_:
|
Sources can be cloned from GitHub_:
|
||||||
|
|
||||||
|
@ -30,7 +35,7 @@ Verification of currently installed version could be done using
|
||||||
|
|
||||||
>>> from dependency_injector import VERSION
|
>>> from dependency_injector import VERSION
|
||||||
>>> VERSION
|
>>> VERSION
|
||||||
'2.0.0'
|
'3.0.0'
|
||||||
|
|
||||||
.. _PyPi: https://pypi.python.org/pypi/dependency_injector
|
.. _PyPi: https://pypi.python.org/pypi/dependency_injector
|
||||||
.. _GitHub: https://github.com/ets-labs/python-dependency-injector
|
.. _GitHub: https://github.com/ets-labs/python-dependency-injector
|
||||||
|
|
|
@ -12,16 +12,7 @@ Current documentation section consists from description of standard providers
|
||||||
library and some useful information like overriding of providers and writing
|
library and some useful information like overriding of providers and writing
|
||||||
of custom providers.
|
of custom providers.
|
||||||
|
|
||||||
All providers are validated in multithreading environment and considered to
|
Providers package API docs - :py:mod:`dependency_injector.providers`
|
||||||
be thread safe.
|
|
||||||
|
|
||||||
+ Base providers class is: :py:class:`dependency_injector.providers.Provider`
|
|
||||||
+ Providers module API docs: :py:mod:`dependency_injector.providers`
|
|
||||||
+ Providers class diagram:
|
|
||||||
|
|
||||||
.. image:: /images/providers/providers_class_diagram.png
|
|
||||||
:width: 100%
|
|
||||||
:align: center
|
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
|
|
@ -33,15 +33,15 @@ Example:
|
||||||
Singleton providers and injections
|
Singleton providers and injections
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
:py:class:`Singleton` provider extends :py:class:`Factory` provider, so, all
|
:py:class:`Singleton` provider has same interface as :py:class:`Factory`
|
||||||
of the rules about injections are the same, as for :py:class:`Factory`
|
provider, so, all of the rules about injections are the same, as for
|
||||||
provider.
|
:py:class:`Factory` provider.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Due that :py:class:`Singleton` provider creates specified class instance
|
Due that :py:class:`Singleton` provider creates specified class instance
|
||||||
only on the first call, all injections are done once, during the first
|
only on the first call, all injections are done once, during the first
|
||||||
call, also. Every next call, while instance has been already created
|
call. Every next call, while instance has been already created
|
||||||
and memorized, no injections are done, :py:class:`Singleton` provider just
|
and memorized, no injections are done, :py:class:`Singleton` provider just
|
||||||
returns memorized earlier instance.
|
returns memorized earlier instance.
|
||||||
|
|
||||||
|
@ -81,10 +81,12 @@ Specialization of :py:class:`Singleton` providers is the same as
|
||||||
Singleton providers and multi-threading
|
Singleton providers and multi-threading
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
:py:class:`Singleton` provider is thread-safe and could be used in
|
:py:class:`Singleton` provider is NOT thread-safe and should be used in
|
||||||
multi-threading applications without any negative impact. Race condition on
|
multi-threading applications with manually controlled locking.
|
||||||
singleton's initialization is escaped by using a global reentrant mutex -
|
|
||||||
:py:obj:`dependency_injector.utils.GLOBAL_LOCK`.
|
:py:class:`ThreadSafeSingleton` is a thread-safe version of
|
||||||
|
:py:class:`Singleton` and could be used in multi-threading applications
|
||||||
|
without any additional locking.
|
||||||
|
|
||||||
Also there could be a need to use thread-scoped singletons and there is a
|
Also there could be a need to use thread-scoped singletons and there is a
|
||||||
special provider for such case - :py:class:`ThreadLocalSingleton`.
|
special provider for such case - :py:class:`ThreadLocalSingleton`.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user