orionis 0.139.0__py3-none-any.whl → 0.151.0__py3-none-any.whl
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.
- orionis/framework.py +1 -1
- orionis/luminate/console/base/command.py +6 -3
- orionis/luminate/console/command_filter.py +1 -1
- orionis/luminate/console/commands/cache_clear.py +4 -3
- orionis/luminate/console/commands/schedule_work.py +1 -1
- orionis/luminate/console/kernel.py +1 -2
- orionis/luminate/console/output/console.py +1 -1
- orionis/luminate/console/output/executor.py +1 -1
- orionis/luminate/console/output/progress_bar.py +1 -1
- orionis/luminate/console/parser.py +1 -1
- orionis/luminate/container/container.py +379 -270
- orionis/luminate/container/container_integrity.py +235 -0
- orionis/luminate/container/lifetimes.py +13 -0
- orionis/luminate/contracts/console/{i_parser.py → parser.py} +0 -1
- orionis/luminate/contracts/container/container.py +346 -0
- orionis/luminate/contracts/container/container_integrity.py +168 -0
- orionis/luminate/facades/commands/commands_facade.py +1 -1
- orionis/luminate/facades/commands/scheduler_facade.py +1 -1
- orionis/luminate/facades/config/config_facade.py +1 -1
- orionis/luminate/facades/environment/environment_facade.py +1 -2
- orionis/luminate/facades/files/path_facade.py +1 -1
- orionis/luminate/facades/log/log_facade.py +1 -1
- orionis/luminate/facades/tests/tests_facade.py +1 -1
- orionis/luminate/foundation/config/config_bootstrapper.py +1 -1
- orionis/luminate/foundation/console/command_bootstrapper.py +1 -1
- orionis/luminate/foundation/environment/environment_bootstrapper.py +1 -1
- orionis/luminate/foundation/providers/service_providers_bootstrapper.py +1 -1
- orionis/luminate/providers/commands/reactor_commands_service_provider.py +2 -1
- orionis/luminate/providers/commands/scheduler_provider.py +2 -1
- orionis/luminate/providers/config/config_service_provider.py +2 -1
- orionis/luminate/providers/environment/environment__service_provider.py +2 -1
- orionis/luminate/providers/files/paths_provider.py +2 -1
- orionis/luminate/providers/log/log_service_provider.py +2 -1
- orionis/luminate/providers/service_provider.py +1 -2
- orionis/luminate/services/commands/reactor_commands_service.py +1 -2
- orionis/luminate/services/commands/scheduler_service.py +1 -2
- orionis/luminate/services/config/config_service.py +1 -2
- orionis/luminate/services/environment/environment_service.py +1 -2
- orionis/luminate/services/files/path_resolver_service.py +1 -2
- orionis/luminate/services/log/log_service.py +1 -2
- orionis/luminate/support/exception_to_dict.py +1 -1
- orionis/luminate/support/reflection.py +1 -1
- orionis/luminate/support/std.py +1 -1
- {orionis-0.139.0.dist-info → orionis-0.151.0.dist-info}/METADATA +1 -1
- {orionis-0.139.0.dist-info → orionis-0.151.0.dist-info}/RECORD +77 -76
- orionis/luminate/container/types.py +0 -51
- orionis/luminate/contracts/container/i_container.py +0 -239
- orionis/luminate/contracts/container/i_types.py +0 -16
- /orionis/luminate/contracts/console/base/{i_command.py → command.py} +0 -0
- /orionis/luminate/contracts/console/{i_command_filter.py → command_filter.py} +0 -0
- /orionis/luminate/contracts/console/{i_kernel.py → kernel.py} +0 -0
- /orionis/luminate/contracts/console/output/{i_console.py → console.py} +0 -0
- /orionis/luminate/contracts/console/output/{i_executor.py → executor.py} +0 -0
- /orionis/luminate/contracts/console/output/{i_progress_bar.py → progress_bar.py} +0 -0
- /orionis/luminate/contracts/console/{i_task_manager.py → task_manager.py} +0 -0
- /orionis/luminate/contracts/facades/commands/{i_commands_facade.py → commands_facade.py} +0 -0
- /orionis/luminate/contracts/facades/commands/{i_scheduler_facade.py → scheduler_facade.py} +0 -0
- /orionis/luminate/contracts/facades/config/{i_config_facade.py → config_facade.py} +0 -0
- /orionis/luminate/contracts/facades/environment/{i_environment_facade.py → environment_facade.py} +0 -0
- /orionis/luminate/contracts/facades/files/{i_path_facade.py → path_facade.py} +0 -0
- /orionis/luminate/contracts/facades/log/{i_log_facade.py → log_facade.py} +0 -0
- /orionis/luminate/contracts/facades/tests/{i_tests_facade.py → tests_facade.py} +0 -0
- /orionis/luminate/contracts/foundation/config/{i_config_bootstrapper.py → config_bootstrapper.py} +0 -0
- /orionis/luminate/contracts/foundation/console/{i_command_bootstrapper.py → command_bootstrapper.py} +0 -0
- /orionis/luminate/contracts/foundation/environment/{i_environment_bootstrapper.py → environment_bootstrapper.py} +0 -0
- /orionis/luminate/contracts/foundation/providers/{i_service_providers_bootstrapper.py → service_providers_bootstrapper.py} +0 -0
- /orionis/luminate/contracts/providers/{i_service_provider.py → service_provider.py} +0 -0
- /orionis/luminate/contracts/services/commands/{i_reactor_commands_service.py → reactor_commands_service.py} +0 -0
- /orionis/luminate/contracts/services/commands/{i_schedule_service.py → schedule_service.py} +0 -0
- /orionis/luminate/contracts/services/config/{i_config_service.py → config_service.py} +0 -0
- /orionis/luminate/contracts/services/environment/{i_environment_service.py → environment_service.py} +0 -0
- /orionis/luminate/contracts/services/files/{i_path_resolver_service.py → path_resolver_service.py} +0 -0
- /orionis/luminate/contracts/services/log/{i_log_service.py → log_service.py} +0 -0
- /orionis/luminate/contracts/support/{i_exception_to_dict.py → exception_to_dict.py} +0 -0
- /orionis/luminate/contracts/support/{i_reflection.py → reflection.py} +0 -0
- /orionis/luminate/contracts/support/{i_std.py → std.py} +0 -0
- {orionis-0.139.0.dist-info → orionis-0.151.0.dist-info}/LICENCE +0 -0
- {orionis-0.139.0.dist-info → orionis-0.151.0.dist-info}/WHEEL +0 -0
- {orionis-0.139.0.dist-info → orionis-0.151.0.dist-info}/entry_points.txt +0 -0
- {orionis-0.139.0.dist-info → orionis-0.151.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,235 @@
|
|
1
|
+
import re
|
2
|
+
import inspect
|
3
|
+
from abc import ABC
|
4
|
+
from typing import Any, Callable, Type
|
5
|
+
from orionis.luminate.container.exception import OrionisContainerValueError, OrionisContainerTypeError
|
6
|
+
from orionis.luminate.contracts.container.container_integrity import IContainerIntegrity
|
7
|
+
|
8
|
+
class ContainerIntegrity(IContainerIntegrity):
|
9
|
+
|
10
|
+
@staticmethod
|
11
|
+
def ensureImplementation(abstract: Type, concrete: Type) -> None:
|
12
|
+
"""
|
13
|
+
Verify at runtime if `concrete` implements all methods of `abstract`.
|
14
|
+
|
15
|
+
:param abstract: Abstract class or interface.
|
16
|
+
:param concrete: Concrete class that should implement the abstract class.
|
17
|
+
:raises TypeError: If `concrete` does not implement all methods of `abstract`.
|
18
|
+
"""
|
19
|
+
# Get public methods of the interface (excluding magic methods)
|
20
|
+
interface_methods = {
|
21
|
+
name for name, func in inspect.getmembers(abstract, predicate=inspect.isfunction)
|
22
|
+
if not name.startswith("_")
|
23
|
+
}
|
24
|
+
|
25
|
+
# Get public methods of the concrete class
|
26
|
+
class_methods = {
|
27
|
+
name for name, func in inspect.getmembers(concrete, predicate=inspect.isfunction)
|
28
|
+
if not name.startswith("_")
|
29
|
+
}
|
30
|
+
|
31
|
+
# Verify that all interface methods are in the concrete class
|
32
|
+
if not interface_methods.issubset(class_methods):
|
33
|
+
missing_methods = interface_methods - class_methods
|
34
|
+
raise OrionisContainerTypeError(f"{concrete.__name__} does not implement the required methods of {abstract.__name__}: {missing_methods}")
|
35
|
+
|
36
|
+
|
37
|
+
@staticmethod
|
38
|
+
def ensureIsAbstract(abstract: Callable[..., Any]) -> None:
|
39
|
+
"""
|
40
|
+
Ensure that the given abstract is a valid abstract class.
|
41
|
+
|
42
|
+
:param abstract: Class to check
|
43
|
+
:raises OrionisContainerValueError: If the class is not a valid abstract interface
|
44
|
+
"""
|
45
|
+
if not isinstance(abstract, type) or not issubclass(abstract, ABC) or abstract is ABC:
|
46
|
+
raise OrionisContainerValueError("The provided class must inherit from ABC and not be ABC itself.")
|
47
|
+
|
48
|
+
if not any(getattr(attr, "__isabstractmethod__", False) for attr in abstract.__dict__.values()):
|
49
|
+
raise OrionisContainerValueError("The provided class must define at least one abstract method.")
|
50
|
+
|
51
|
+
@staticmethod
|
52
|
+
def ensureIsCallable(concrete: Callable[..., Any]) -> None:
|
53
|
+
"""
|
54
|
+
Ensure that the given implementation is callable or instantiable.
|
55
|
+
|
56
|
+
Parameters
|
57
|
+
----------
|
58
|
+
concrete : Callable[..., Any]
|
59
|
+
The implementation to check.
|
60
|
+
|
61
|
+
Raises
|
62
|
+
------
|
63
|
+
OrionisContainerTypeError
|
64
|
+
If the implementation is not callable.
|
65
|
+
"""
|
66
|
+
if not callable(concrete):
|
67
|
+
raise OrionisContainerTypeError(f"The implementation '{str(concrete)}' must be callable or an instantiable class.")
|
68
|
+
|
69
|
+
@staticmethod
|
70
|
+
def ensureIsInstance(instance: Any) -> None:
|
71
|
+
"""
|
72
|
+
Ensure that the given instance is a valid object.
|
73
|
+
|
74
|
+
Parameters
|
75
|
+
----------
|
76
|
+
instance : Any
|
77
|
+
The instance to check.
|
78
|
+
|
79
|
+
Raises
|
80
|
+
------
|
81
|
+
OrionisContainerValueError
|
82
|
+
If the instance is not a valid object.
|
83
|
+
"""
|
84
|
+
if not isinstance(instance, object):
|
85
|
+
raise OrionisContainerValueError(f"The instance '{str(instance)}' must be a valid object.")
|
86
|
+
|
87
|
+
module = type(instance).__module__
|
88
|
+
if module in ['builtins', 'abc']:
|
89
|
+
raise OrionisContainerValueError(f"The instance '{str(instance)}' is not a valid user-defined object. It belongs to the '{module}' module.")
|
90
|
+
|
91
|
+
@staticmethod
|
92
|
+
def ensureNotMain(concrete: Callable[..., Any]) -> str:
|
93
|
+
"""
|
94
|
+
Ensure that a class is not defined in the main script.
|
95
|
+
|
96
|
+
Parameters
|
97
|
+
----------
|
98
|
+
concrete : Callable[..., Any]
|
99
|
+
The class or function to check.
|
100
|
+
|
101
|
+
Returns
|
102
|
+
-------
|
103
|
+
str
|
104
|
+
The fully qualified name of the class.
|
105
|
+
|
106
|
+
Raises
|
107
|
+
------
|
108
|
+
OrionisContainerValueError
|
109
|
+
If the class is defined in the main module.
|
110
|
+
"""
|
111
|
+
if concrete.__module__ == "__main__":
|
112
|
+
raise OrionisContainerValueError("Cannot register a class from the (__main__) module in the container.")
|
113
|
+
|
114
|
+
@staticmethod
|
115
|
+
def ensureIsAlias(name: str) -> bool:
|
116
|
+
"""
|
117
|
+
Ensure that the given alias name is a valid string, with no special characters or spaces,
|
118
|
+
and it is not a primitive type.
|
119
|
+
|
120
|
+
Parameters
|
121
|
+
----------
|
122
|
+
name : str
|
123
|
+
The alias name to check.
|
124
|
+
|
125
|
+
Raises
|
126
|
+
------
|
127
|
+
OrionisContainerValueError
|
128
|
+
If the alias is invalid.
|
129
|
+
"""
|
130
|
+
if not isinstance(name, str):
|
131
|
+
raise OrionisContainerValueError(f"The alias '{name}' must be a string.")
|
132
|
+
|
133
|
+
if not re.match(r'^[a-zA-Z0-9]+$', name):
|
134
|
+
raise OrionisContainerValueError(f"The alias '{name}' can only contain letters and numbers, without spaces or special characters.")
|
135
|
+
|
136
|
+
if name in {
|
137
|
+
int, "int",
|
138
|
+
float, "float",
|
139
|
+
str, "str",
|
140
|
+
bool, "bool",
|
141
|
+
bytes, "bytes",
|
142
|
+
type(None), "None",
|
143
|
+
complex, "complex",
|
144
|
+
list, "list",
|
145
|
+
tuple, "tuple",
|
146
|
+
dict, "dict",
|
147
|
+
set, "set",
|
148
|
+
frozenset, "frozenset"
|
149
|
+
}:
|
150
|
+
raise OrionisContainerValueError(f"The alias '{name}' cannot be a primitive type.")
|
151
|
+
|
152
|
+
@staticmethod
|
153
|
+
def isAlias(name: str) -> bool:
|
154
|
+
"""
|
155
|
+
Check if the given alias name is a valid string, with no special characters or spaces,
|
156
|
+
and it is not a primitive type.
|
157
|
+
|
158
|
+
Parameters
|
159
|
+
----------
|
160
|
+
name : str
|
161
|
+
The alias name to check.
|
162
|
+
|
163
|
+
Returns
|
164
|
+
-------
|
165
|
+
bool
|
166
|
+
True if the alias is valid, False otherwise.
|
167
|
+
"""
|
168
|
+
try:
|
169
|
+
ContainerIntegrity.ensureIsAlias(name)
|
170
|
+
return True
|
171
|
+
except OrionisContainerValueError:
|
172
|
+
return False
|
173
|
+
|
174
|
+
@staticmethod
|
175
|
+
def isCallable(concrete: Callable[..., Any]) -> bool:
|
176
|
+
"""
|
177
|
+
Check if the given implementation is callable or instantiable.
|
178
|
+
|
179
|
+
Parameters
|
180
|
+
----------
|
181
|
+
concrete : Callable[..., Any]
|
182
|
+
The implementation to check.
|
183
|
+
|
184
|
+
Returns
|
185
|
+
-------
|
186
|
+
bool
|
187
|
+
True if the implementation is callable, False otherwise.
|
188
|
+
"""
|
189
|
+
try:
|
190
|
+
ContainerIntegrity.ensureIsCallable(concrete)
|
191
|
+
return True
|
192
|
+
except OrionisContainerTypeError:
|
193
|
+
return False
|
194
|
+
|
195
|
+
@staticmethod
|
196
|
+
def isInstance(instance: Any) -> bool:
|
197
|
+
"""
|
198
|
+
Check if the given instance is a valid object.
|
199
|
+
|
200
|
+
Parameters
|
201
|
+
----------
|
202
|
+
instance : Any
|
203
|
+
The instance to check.
|
204
|
+
|
205
|
+
Returns
|
206
|
+
-------
|
207
|
+
bool
|
208
|
+
True if the instance is valid, False otherwise.
|
209
|
+
"""
|
210
|
+
try:
|
211
|
+
ContainerIntegrity.ensureIsInstance(instance)
|
212
|
+
return True
|
213
|
+
except OrionisContainerValueError:
|
214
|
+
return False
|
215
|
+
|
216
|
+
@staticmethod
|
217
|
+
def isAbstract(abstract: Callable[..., Any]) -> bool:
|
218
|
+
"""
|
219
|
+
Check if the given abstract is a valid abstract class.
|
220
|
+
|
221
|
+
Parameters
|
222
|
+
----------
|
223
|
+
abstract : Callable[..., Any]
|
224
|
+
The class to check.
|
225
|
+
|
226
|
+
Returns
|
227
|
+
-------
|
228
|
+
bool
|
229
|
+
True if the class is a valid abstract interface, False otherwise.
|
230
|
+
"""
|
231
|
+
try:
|
232
|
+
ContainerIntegrity.ensureIsAbstract(abstract)
|
233
|
+
return True
|
234
|
+
except OrionisContainerValueError:
|
235
|
+
return False
|
@@ -0,0 +1,13 @@
|
|
1
|
+
from enum import Enum
|
2
|
+
|
3
|
+
class Lifetime(Enum):
|
4
|
+
"""Defines the lifecycle types for dependency injection."""
|
5
|
+
|
6
|
+
# Creates a new instance every time it is requested
|
7
|
+
TRANSIENT = "transient"
|
8
|
+
|
9
|
+
# A single instance is shared throughout the application
|
10
|
+
SINGLETON = "singleton"
|
11
|
+
|
12
|
+
# A new instance is created per request or context
|
13
|
+
SCOPED = "scoped"
|
@@ -0,0 +1,346 @@
|
|
1
|
+
from abc import ABC, abstractmethod
|
2
|
+
|
3
|
+
class IContainer(ABC):
|
4
|
+
|
5
|
+
@abstractmethod
|
6
|
+
def bind(self, abstract, concrete, lifetime):
|
7
|
+
"""
|
8
|
+
Binds an abstract type to a concrete implementation with a specified lifetime.
|
9
|
+
|
10
|
+
Parameters
|
11
|
+
----------
|
12
|
+
abstract : Callable[..., Any]
|
13
|
+
The abstract base type or alias to be bound.
|
14
|
+
concrete : Callable[..., Any]
|
15
|
+
The concrete implementation to associate with the abstract type.
|
16
|
+
lifetime : str
|
17
|
+
The lifecycle of the binding. Must be one of 'transient', 'scoped', or 'singleton'.
|
18
|
+
|
19
|
+
Raises
|
20
|
+
------
|
21
|
+
OrionisContainerValueError
|
22
|
+
If an invalid lifetime is provided or the concrete implementation is None.
|
23
|
+
|
24
|
+
Examples
|
25
|
+
--------
|
26
|
+
>>> container.bind(MyService, MyServiceImplementation, "singleton")
|
27
|
+
"""
|
28
|
+
pass
|
29
|
+
|
30
|
+
@abstractmethod
|
31
|
+
def transient(self, abstract, concrete):
|
32
|
+
"""
|
33
|
+
Registers a service with a transient lifetime.
|
34
|
+
|
35
|
+
Parameters
|
36
|
+
----------
|
37
|
+
abstract : Callable[..., Any]
|
38
|
+
The abstract base type or alias to be bound.
|
39
|
+
concrete : Callable[..., Any]
|
40
|
+
The concrete implementation to associate with the abstract type.
|
41
|
+
|
42
|
+
Examples
|
43
|
+
--------
|
44
|
+
>>> container.transient(MyService, MyServiceImplementation)
|
45
|
+
"""
|
46
|
+
pass
|
47
|
+
|
48
|
+
@abstractmethod
|
49
|
+
def scoped(self, abstract, concrete):
|
50
|
+
"""
|
51
|
+
Registers a service with a scoped lifetime.
|
52
|
+
|
53
|
+
Parameters
|
54
|
+
----------
|
55
|
+
abstract : Callable[..., Any]
|
56
|
+
The abstract base type or alias to be bound.
|
57
|
+
concrete : Callable[..., Any]
|
58
|
+
The concrete implementation to associate with the abstract type.
|
59
|
+
|
60
|
+
Examples
|
61
|
+
--------
|
62
|
+
>>> container.scoped(MyService, MyServiceImplementation)
|
63
|
+
"""
|
64
|
+
pass
|
65
|
+
|
66
|
+
@abstractmethod
|
67
|
+
def singleton(self, abstract, concrete):
|
68
|
+
"""
|
69
|
+
Registers a service with a singleton lifetime.
|
70
|
+
|
71
|
+
Parameters
|
72
|
+
----------
|
73
|
+
abstract : Callable[..., Any]
|
74
|
+
The abstract base type or alias to be bound.
|
75
|
+
concrete : Callable[..., Any]
|
76
|
+
The concrete implementation to associate with the abstract type.
|
77
|
+
|
78
|
+
Examples
|
79
|
+
--------
|
80
|
+
>>> container.singleton(MyService, MyServiceImplementation)
|
81
|
+
"""
|
82
|
+
pass
|
83
|
+
|
84
|
+
@abstractmethod
|
85
|
+
def instance(self, abstract, instance):
|
86
|
+
"""
|
87
|
+
Registers an already instantiated object in the container.
|
88
|
+
|
89
|
+
Parameters
|
90
|
+
----------
|
91
|
+
abstract : Callable[..., Any]
|
92
|
+
The abstract base type or alias to be bound.
|
93
|
+
instance : Any
|
94
|
+
The instance to be stored.
|
95
|
+
|
96
|
+
Raises
|
97
|
+
------
|
98
|
+
OrionisContainerValueError
|
99
|
+
If the instance is None.
|
100
|
+
|
101
|
+
Examples
|
102
|
+
--------
|
103
|
+
>>> container.instance(MyService, my_service_instance)
|
104
|
+
"""
|
105
|
+
pass
|
106
|
+
|
107
|
+
@abstractmethod
|
108
|
+
def bound(self, abstract_or_alias):
|
109
|
+
"""
|
110
|
+
Checks if a service or alias is bound in the container.
|
111
|
+
|
112
|
+
Parameters
|
113
|
+
----------
|
114
|
+
abstract_or_alias : Callable[..., Any]
|
115
|
+
The abstract type or alias to check.
|
116
|
+
|
117
|
+
Returns
|
118
|
+
-------
|
119
|
+
bool
|
120
|
+
True if the service is bound, False otherwise.
|
121
|
+
|
122
|
+
Examples
|
123
|
+
--------
|
124
|
+
>>> container.bound(MyService)
|
125
|
+
True
|
126
|
+
"""
|
127
|
+
pass
|
128
|
+
|
129
|
+
@abstractmethod
|
130
|
+
def has(self, abstract_or_alias):
|
131
|
+
"""
|
132
|
+
Alias for `bound()` method.
|
133
|
+
|
134
|
+
Parameters
|
135
|
+
----------
|
136
|
+
abstract_or_alias : Callable[..., Any]
|
137
|
+
The abstract type or alias to check.
|
138
|
+
|
139
|
+
Returns
|
140
|
+
-------
|
141
|
+
bool
|
142
|
+
True if the service is bound, False otherwise.
|
143
|
+
|
144
|
+
Examples
|
145
|
+
--------
|
146
|
+
>>> container.has(MyService)
|
147
|
+
True
|
148
|
+
"""
|
149
|
+
pass
|
150
|
+
|
151
|
+
@abstractmethod
|
152
|
+
def alias(self, alias, abstract):
|
153
|
+
"""
|
154
|
+
Creates an alias for an existing abstract binding.
|
155
|
+
|
156
|
+
Parameters
|
157
|
+
----------
|
158
|
+
alias : Callable[..., Any]
|
159
|
+
The alias name.
|
160
|
+
abstract : Callable[..., Any]
|
161
|
+
The existing abstract type to alias.
|
162
|
+
|
163
|
+
Raises
|
164
|
+
------
|
165
|
+
OrionisContainerValueError
|
166
|
+
If the abstract type is not registered or the alias is already in use.
|
167
|
+
|
168
|
+
Examples
|
169
|
+
--------
|
170
|
+
>>> container.alias("DatabaseService", MyDatabaseService)
|
171
|
+
"""
|
172
|
+
pass
|
173
|
+
|
174
|
+
@abstractmethod
|
175
|
+
def isAlias(self, name):
|
176
|
+
"""
|
177
|
+
Checks if a given name is an alias.
|
178
|
+
|
179
|
+
Parameters
|
180
|
+
----------
|
181
|
+
name : str
|
182
|
+
The name to check.
|
183
|
+
|
184
|
+
Returns
|
185
|
+
-------
|
186
|
+
bool
|
187
|
+
True if the name is an alias, False otherwise.
|
188
|
+
|
189
|
+
Raises
|
190
|
+
------
|
191
|
+
OrionisContainerTypeError
|
192
|
+
If the name is not a string.
|
193
|
+
|
194
|
+
Examples
|
195
|
+
--------
|
196
|
+
>>> container.isAlias("DatabaseService")
|
197
|
+
True
|
198
|
+
"""
|
199
|
+
pass
|
200
|
+
|
201
|
+
@abstractmethod
|
202
|
+
def getBindings(self):
|
203
|
+
"""
|
204
|
+
Retrieves all registered service bindings.
|
205
|
+
|
206
|
+
Returns
|
207
|
+
-------
|
208
|
+
dict
|
209
|
+
A dictionary containing all instances, transient, scoped, singleton, and alias services.
|
210
|
+
|
211
|
+
Examples
|
212
|
+
--------
|
213
|
+
>>> container.getBindings()
|
214
|
+
"""
|
215
|
+
pass
|
216
|
+
|
217
|
+
@abstractmethod
|
218
|
+
def getAlias(self, name):
|
219
|
+
"""
|
220
|
+
Retrieves the abstract type associated with an alias.
|
221
|
+
|
222
|
+
Parameters
|
223
|
+
----------
|
224
|
+
name : str
|
225
|
+
The alias name.
|
226
|
+
|
227
|
+
Returns
|
228
|
+
-------
|
229
|
+
Callable[..., Any]
|
230
|
+
The abstract type associated with the alias.
|
231
|
+
|
232
|
+
Raises
|
233
|
+
------
|
234
|
+
OrionisContainerValueError
|
235
|
+
If the alias is not registered.
|
236
|
+
|
237
|
+
Examples
|
238
|
+
--------
|
239
|
+
>>> container.getAlias("DatabaseService")
|
240
|
+
<class 'MyDatabaseService'>
|
241
|
+
"""
|
242
|
+
pass
|
243
|
+
|
244
|
+
@abstractmethod
|
245
|
+
def forgetScopedInstances(self):
|
246
|
+
"""
|
247
|
+
Clears all scoped instances.
|
248
|
+
|
249
|
+
Examples
|
250
|
+
--------
|
251
|
+
>>> container.forgetScopedInstances()
|
252
|
+
"""
|
253
|
+
pass
|
254
|
+
|
255
|
+
@abstractmethod
|
256
|
+
def newRequest(self):
|
257
|
+
"""
|
258
|
+
Resets scoped instances to handle a new request.
|
259
|
+
|
260
|
+
Examples
|
261
|
+
--------
|
262
|
+
>>> container.newRequest()
|
263
|
+
"""
|
264
|
+
pass
|
265
|
+
|
266
|
+
@abstractmethod
|
267
|
+
async def make(self, abstract_or_alias):
|
268
|
+
"""
|
269
|
+
Resolves and instantiates a service from the container.
|
270
|
+
|
271
|
+
Parameters
|
272
|
+
----------
|
273
|
+
abstract_or_alias : Callable[..., Any]
|
274
|
+
The abstract type or alias to resolve.
|
275
|
+
|
276
|
+
Returns
|
277
|
+
-------
|
278
|
+
Any
|
279
|
+
The instantiated service.
|
280
|
+
|
281
|
+
Raises
|
282
|
+
------
|
283
|
+
OrionisContainerException
|
284
|
+
If the service is not found.
|
285
|
+
|
286
|
+
Examples
|
287
|
+
--------
|
288
|
+
>>> service = await container.make(MyService)
|
289
|
+
"""
|
290
|
+
pass
|
291
|
+
|
292
|
+
@abstractmethod
|
293
|
+
def _resolve(self, concrete, resolving=None):
|
294
|
+
"""
|
295
|
+
Resolves dependencies recursively and instantiates a class.
|
296
|
+
|
297
|
+
Parameters
|
298
|
+
----------
|
299
|
+
concrete : Callable[..., Any]
|
300
|
+
The concrete implementation to instantiate.
|
301
|
+
resolving : Optional[Deque[Type]], optional
|
302
|
+
A queue to track resolving dependencies and prevent circular dependencies.
|
303
|
+
|
304
|
+
Returns
|
305
|
+
-------
|
306
|
+
Any
|
307
|
+
The instantiated object.
|
308
|
+
|
309
|
+
Raises
|
310
|
+
------
|
311
|
+
OrionisContainerException
|
312
|
+
If circular dependencies are detected or instantiation fails.
|
313
|
+
|
314
|
+
Examples
|
315
|
+
--------
|
316
|
+
>>> instance = container._resolve(MyClass)
|
317
|
+
"""
|
318
|
+
pass
|
319
|
+
|
320
|
+
@abstractmethod
|
321
|
+
def _resolve_dependency(self, dep_type, resolving=None):
|
322
|
+
"""
|
323
|
+
Resolves a dependency by instantiating or retrieving it from the container.
|
324
|
+
|
325
|
+
Parameters
|
326
|
+
----------
|
327
|
+
dep_type : Any
|
328
|
+
The dependency type to resolve.
|
329
|
+
resolving : Optional[Deque[Type]], optional
|
330
|
+
A queue to track resolving dependencies.
|
331
|
+
|
332
|
+
Returns
|
333
|
+
-------
|
334
|
+
Any
|
335
|
+
The resolved dependency.
|
336
|
+
|
337
|
+
Raises
|
338
|
+
------
|
339
|
+
OrionisContainerException
|
340
|
+
If the dependency cannot be resolved.
|
341
|
+
|
342
|
+
Examples
|
343
|
+
--------
|
344
|
+
>>> dependency = container._resolve_dependency(MyDependency)
|
345
|
+
"""
|
346
|
+
pass
|