explicit-python 2.2.1__tar.gz → 2.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. {explicit_python-2.2.1/src/explicit_python.egg-info → explicit_python-2.3.1}/PKG-INFO +10 -2
  2. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/messagebus/commands.py +10 -5
  3. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/messagebus/dependency_injection.py +12 -0
  4. explicit_python-2.3.1/src/explicit/messagebus/exceptions.py +8 -0
  5. {explicit_python-2.2.1 → explicit_python-2.3.1/src/explicit_python.egg-info}/PKG-INFO +10 -2
  6. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit_python.egg-info/SOURCES.txt +1 -0
  7. {explicit_python-2.2.1 → explicit_python-2.3.1}/version.conf +5 -5
  8. {explicit_python-2.2.1 → explicit_python-2.3.1}/MANIFEST.in +0 -0
  9. {explicit_python-2.2.1 → explicit_python-2.3.1}/README.md +0 -0
  10. {explicit_python-2.2.1 → explicit_python-2.3.1}/setup.cfg +0 -0
  11. {explicit_python-2.2.1 → explicit_python-2.3.1}/setup.py +0 -0
  12. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/adapters/__init__.py +0 -0
  13. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/adapters/db.py +0 -0
  14. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/adapters/fs.py +0 -0
  15. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/adapters/messaging.py +0 -0
  16. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/contrib/__init__.py +0 -0
  17. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/contrib/domain/__init__.py +0 -0
  18. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/contrib/domain/model/__init__.py +0 -0
  19. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/contrib/domain/model/fields.py +0 -0
  20. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/contrib/messagebus/__init__.py +0 -0
  21. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/contrib/messagebus/event_registry.py +0 -0
  22. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/domain/__init__.py +0 -0
  23. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/domain/factories.py +0 -0
  24. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/domain/fields.py +0 -0
  25. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/domain/model.py +0 -0
  26. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/domain/types.py +0 -0
  27. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/domain/validation/__init__.py +0 -0
  28. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/domain/validation/exceptions.py +0 -0
  29. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/messagebus/__init__.py +0 -0
  30. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/messagebus/events.py +0 -0
  31. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/messagebus/messagebus.py +0 -0
  32. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/messagebus/queries.py +0 -0
  33. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/py.typed +0 -0
  34. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit/unit_of_work.py +0 -0
  35. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit_python.egg-info/dependency_links.txt +0 -0
  36. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit_python.egg-info/requires.txt +0 -0
  37. {explicit_python-2.2.1 → explicit_python-2.3.1}/src/explicit_python.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: explicit-python
3
- Version: 2.2.1
3
+ Version: 2.3.1
4
4
  Summary: Набор компонентов для построения многослойной архитектуры
5
5
  Author: BARS Group
6
6
  Author-email: education_dev@bars-open.ru
@@ -18,6 +18,14 @@ Classifier: Development Status :: 5 - Production/Stable
18
18
  Description-Content-Type: text/markdown
19
19
  Requires-Dist: pydantic<2.0
20
20
  Requires-Dist: more_itertools
21
+ Dynamic: author
22
+ Dynamic: author-email
23
+ Dynamic: classifier
24
+ Dynamic: description
25
+ Dynamic: description-content-type
26
+ Dynamic: license
27
+ Dynamic: requires-dist
28
+ Dynamic: summary
21
29
 
22
30
  # Explicit
23
31
  ## Набор компонентов для построения явной (Explicit) многослойной архитектуры
@@ -10,6 +10,8 @@ from pydantic.main import BaseModel
10
10
 
11
11
  from explicit.domain import HasUnsetValues
12
12
 
13
+ from .exceptions import NoHandlerError
14
+
13
15
 
14
16
  class Command(HasUnsetValues, BaseModel):
15
17
 
@@ -78,6 +80,7 @@ class CommandBusMixin(ABC):
78
80
 
79
81
  def add_command_handler(self, command: Type[Command], handler: CommandHandler) -> None:
80
82
  """Регистрация обработчика команды."""
83
+
81
84
  assert issubclass(command, Command)
82
85
  assert callable(handler)
83
86
  self._command_handlers[command] = handler
@@ -87,14 +90,16 @@ class CommandBusMixin(ABC):
87
90
  *handlers: Tuple[Type[Command], CommandHandler]
88
91
  ) -> None:
89
92
  """Регистрация обработчиков команд."""
93
+
90
94
  for command, handler in handlers:
91
95
  self.add_command_handler(command, handler)
92
96
 
93
97
  def handle_command(self, command: Command):
94
- """Передача запроса обработчику типа данного команды."""
98
+ """Передача запроса обработчику типа данной команды."""
95
99
 
96
100
  assert isinstance(command, Command)
97
- try:
98
- return self._command_handlers[type(command)](command)
99
- except KeyError as e:
100
- raise ValueError(f'No handler for {type(command)}') from e
101
+ handler = self._command_handlers.get(type(command))
102
+ if handler is None:
103
+ raise NoHandlerError(type(command))
104
+
105
+ return handler(command)
@@ -16,12 +16,24 @@ class UnknownDependencyError(Exception):
16
16
  """Ожидаемая обработчиком зависимость не зарегистрирована."""
17
17
 
18
18
 
19
+ class AlreadyRegisteredDependencyError(Exception):
20
+ """Зависимость с таким именем уже зарегистрирована."""
21
+
22
+
19
23
  class DependencyInjectionMixin:
20
24
 
21
25
  """Примесь к шине сообщений, реализует управление зависимостями и их внедрение."""
22
26
 
23
27
  _dependencies: Dict[str, Callable]
24
28
 
29
+ def register_dependency(self, alias: str, dependency: Callable):
30
+ """Зарегистрировать зависимость."""
31
+ if alias in self._dependencies:
32
+ raise AlreadyRegisteredDependencyError(f'Зависимость с именем {alias} именем уже зарегистрирована')
33
+
34
+ self._dependencies[alias] = dependency
35
+ logger.debug('Зарегистрирована зависимость %s', alias)
36
+
25
37
  def _set_dependencies(self, **dependencies: Any):
26
38
  """Заменяет внутреннее сопоставление зависимостей."""
27
39
  self._dependencies = dependencies
@@ -0,0 +1,8 @@
1
+ from typing import Any
2
+
3
+
4
+ class NoHandlerError(ValueError):
5
+ """Обработчик для данного сообщения не зарегистрирован."""
6
+
7
+ def __init__(self, message_cls: type[Any], *args, **kwargs):
8
+ super().__init__(f'No handler for {message_cls}', *args, **kwargs)
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: explicit-python
3
- Version: 2.2.1
3
+ Version: 2.3.1
4
4
  Summary: Набор компонентов для построения многослойной архитектуры
5
5
  Author: BARS Group
6
6
  Author-email: education_dev@bars-open.ru
@@ -18,6 +18,14 @@ Classifier: Development Status :: 5 - Production/Stable
18
18
  Description-Content-Type: text/markdown
19
19
  Requires-Dist: pydantic<2.0
20
20
  Requires-Dist: more_itertools
21
+ Dynamic: author
22
+ Dynamic: author-email
23
+ Dynamic: classifier
24
+ Dynamic: description
25
+ Dynamic: description-content-type
26
+ Dynamic: license
27
+ Dynamic: requires-dist
28
+ Dynamic: summary
21
29
 
22
30
  # Explicit
23
31
  ## Набор компонентов для построения явной (Explicit) многослойной архитектуры
@@ -25,6 +25,7 @@ src/explicit/messagebus/__init__.py
25
25
  src/explicit/messagebus/commands.py
26
26
  src/explicit/messagebus/dependency_injection.py
27
27
  src/explicit/messagebus/events.py
28
+ src/explicit/messagebus/exceptions.py
28
29
  src/explicit/messagebus/messagebus.py
29
30
  src/explicit/messagebus/queries.py
30
31
  src/explicit_python.egg-info/PKG-INFO
@@ -4,8 +4,8 @@
4
4
  # нормальной установки обновлений.
5
5
 
6
6
  [version]
7
- BRANCH = tags/2.2.1
8
- VERSION = 2.2.1
9
- REVISION = 1d5a0181bfa7e9e841727c799144bc9b94623b69
10
- VERSION_DATE = 02.10.2024
11
- REVISION_DATE = 02.10.2024
7
+ BRANCH = tags/2.3.1
8
+ VERSION = 2.3.1
9
+ REVISION = e53df817ef68c829e650d832e2fc7d3003df2777
10
+ VERSION_DATE = 17.10.2025
11
+ REVISION_DATE = 17.10.2025