orionis 0.612.0__py3-none-any.whl → 0.614.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/container/providers/service_provider.py +31 -9
- orionis/foundation/application.py +70 -48
- orionis/foundation/exceptions/application.py +51 -4
- orionis/foundation/providers/catch_provider.py +11 -32
- orionis/foundation/providers/cli_request_provider.py +13 -28
- orionis/foundation/providers/console_provider.py +14 -48
- orionis/foundation/providers/directory_provider.py +13 -39
- orionis/foundation/providers/dumper_provider.py +13 -63
- orionis/foundation/providers/executor_provider.py +13 -62
- orionis/foundation/providers/inspirational_provider.py +12 -65
- orionis/foundation/providers/logger_provider.py +15 -58
- orionis/foundation/providers/performance_counter_provider.py +13 -39
- orionis/foundation/providers/progress_bar_provider.py +11 -66
- orionis/foundation/providers/reactor_provider.py +14 -65
- orionis/foundation/providers/scheduler_provider.py +13 -35
- orionis/foundation/providers/testing_provider.py +9 -55
- orionis/foundation/providers/workers_provider.py +17 -76
- orionis/metadata/framework.py +1 -1
- orionis/support/facades/application.py +8 -10
- orionis/support/facades/console.py +8 -9
- orionis/support/facades/directory.py +9 -8
- orionis/support/facades/dumper.py +7 -8
- orionis/support/facades/executor.py +10 -11
- orionis/support/facades/inspire.py +9 -10
- orionis/support/facades/logger.py +10 -10
- orionis/support/facades/performance_counter.py +9 -8
- orionis/support/facades/progress_bar.py +10 -8
- orionis/support/facades/reactor.py +9 -9
- orionis/support/facades/testing.py +8 -9
- orionis/support/facades/workers.py +8 -8
- {orionis-0.612.0.dist-info → orionis-0.614.0.dist-info}/METADATA +1 -1
- {orionis-0.612.0.dist-info → orionis-0.614.0.dist-info}/RECORD +35 -36
- orionis/foundation/contracts/config.py +0 -31
- {orionis-0.612.0.dist-info → orionis-0.614.0.dist-info}/WHEEL +0 -0
- {orionis-0.612.0.dist-info → orionis-0.614.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.612.0.dist-info → orionis-0.614.0.dist-info}/top_level.txt +0 -0
|
@@ -16,35 +16,57 @@ class ServiceProvider(IServiceProvider):
|
|
|
16
16
|
|
|
17
17
|
def __init__(self, app: IApplication) -> None:
|
|
18
18
|
"""
|
|
19
|
-
Initialize
|
|
19
|
+
Initialize a new ServiceProvider instance with the given application container.
|
|
20
20
|
|
|
21
21
|
Parameters
|
|
22
22
|
----------
|
|
23
23
|
app : IApplication
|
|
24
|
-
The application container instance.
|
|
24
|
+
The application container instance to which this service provider will be attached.
|
|
25
|
+
|
|
26
|
+
Returns
|
|
27
|
+
-------
|
|
28
|
+
None
|
|
29
|
+
This constructor does not return a value.
|
|
25
30
|
"""
|
|
31
|
+
|
|
32
|
+
# Store the application container instance for use in service registration and bootstrapping
|
|
26
33
|
self.app = app
|
|
27
34
|
|
|
28
35
|
async def register(self) -> None:
|
|
29
36
|
"""
|
|
30
37
|
Register services and components into the application container.
|
|
31
38
|
|
|
32
|
-
This method
|
|
33
|
-
configurations, or other components to the application container.
|
|
39
|
+
This asynchronous method should be implemented by subclasses to bind services,
|
|
40
|
+
configurations, or other components to the application container. It is called
|
|
41
|
+
during the application's service registration phase.
|
|
42
|
+
|
|
43
|
+
Returns
|
|
44
|
+
-------
|
|
45
|
+
None
|
|
46
|
+
This method does not return a value.
|
|
34
47
|
|
|
35
48
|
Raises
|
|
36
49
|
------
|
|
37
50
|
NotImplementedError
|
|
38
51
|
If the method is not overridden in a subclass.
|
|
39
52
|
"""
|
|
40
|
-
|
|
53
|
+
|
|
54
|
+
# Optionally overridden by subclasses to register services
|
|
55
|
+
pass
|
|
41
56
|
|
|
42
57
|
async def boot(self) -> None:
|
|
43
58
|
"""
|
|
44
|
-
Perform post-registration initialization or bootstrapping.
|
|
59
|
+
Perform post-registration initialization or bootstrapping tasks.
|
|
60
|
+
|
|
61
|
+
This asynchronous method is called after all services have been registered.
|
|
62
|
+
Subclasses may override this method to initialize services, set up event listeners,
|
|
63
|
+
or perform other operations required at application boot time.
|
|
45
64
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
65
|
+
Returns
|
|
66
|
+
-------
|
|
67
|
+
None
|
|
68
|
+
This method does not return a value.
|
|
49
69
|
"""
|
|
70
|
+
|
|
71
|
+
# Optionally overridden by subclasses to perform boot-time operations
|
|
50
72
|
pass
|
|
@@ -23,7 +23,6 @@ from orionis.foundation.config.startup import Configuration
|
|
|
23
23
|
from orionis.foundation.config.testing.entities.testing import Testing
|
|
24
24
|
from orionis.foundation.contracts.application import IApplication
|
|
25
25
|
from orionis.foundation.exceptions import OrionisTypeError, OrionisRuntimeError, OrionisValueError
|
|
26
|
-
from orionis.services.asynchrony.coroutines import Coroutine
|
|
27
26
|
from orionis.services.log.contracts.log_service import ILogger
|
|
28
27
|
from orionis.support.wrapper.dataclass import DataClass
|
|
29
28
|
|
|
@@ -162,11 +161,7 @@ class Application(Container, IApplication):
|
|
|
162
161
|
|
|
163
162
|
# Register each kernel instance
|
|
164
163
|
for abstract, concrete in core_kernels.items():
|
|
165
|
-
self.instance(
|
|
166
|
-
abstract,
|
|
167
|
-
concrete(self),
|
|
168
|
-
alias=f"x-{abstract.__module__}.{abstract.__name__}"
|
|
169
|
-
)
|
|
164
|
+
self.instance(abstract, concrete(self), alias=f"x-{abstract.__module__}.{abstract.__name__}")
|
|
170
165
|
|
|
171
166
|
def __loadFrameworkProviders(
|
|
172
167
|
self
|
|
@@ -324,75 +319,102 @@ class Application(Container, IApplication):
|
|
|
324
319
|
"""
|
|
325
320
|
Instantiate and register all service providers in the container.
|
|
326
321
|
|
|
327
|
-
This method iterates through all
|
|
328
|
-
with the current application instance, and
|
|
329
|
-
to bind services into the dependency injection container.
|
|
330
|
-
|
|
322
|
+
This private method iterates through all service provider classes previously added to the application,
|
|
323
|
+
instantiates each provider with the current application instance, and invokes their `register()` method
|
|
324
|
+
to bind services into the dependency injection container. Both synchronous and asynchronous `register()`
|
|
325
|
+
methods are supported and handled appropriately.
|
|
326
|
+
|
|
327
|
+
After registration, the internal providers list is updated to contain the instantiated provider objects
|
|
328
|
+
instead of class references. This ensures that subsequent booting operations are performed on the actual
|
|
329
|
+
provider instances.
|
|
331
330
|
|
|
332
331
|
Notes
|
|
333
332
|
-----
|
|
334
|
-
This is
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
333
|
+
- This method is called automatically during application bootstrapping.
|
|
334
|
+
- Handles both coroutine and regular `register()` methods using `asyncio` when necessary.
|
|
335
|
+
- The providers list is updated in-place to hold provider instances.
|
|
336
|
+
|
|
337
|
+
Returns
|
|
338
|
+
-------
|
|
339
|
+
None
|
|
340
|
+
This method does not return any value. It updates the internal state of the application by
|
|
341
|
+
replacing the provider class references with their instantiated objects.
|
|
338
342
|
"""
|
|
339
343
|
|
|
340
|
-
#
|
|
344
|
+
# Prepare a list to hold initialized provider instances
|
|
341
345
|
initialized_providers = []
|
|
342
346
|
|
|
343
|
-
# Iterate over each provider
|
|
344
|
-
for
|
|
347
|
+
# Iterate over each provider class in the providers list
|
|
348
|
+
for provider_cls in self.__providers:
|
|
345
349
|
|
|
346
|
-
#
|
|
347
|
-
|
|
350
|
+
# Instantiate the provider with the current application instance
|
|
351
|
+
provider_instance = provider_cls(self)
|
|
348
352
|
|
|
349
|
-
#
|
|
350
|
-
|
|
351
|
-
if asyncio.iscoroutinefunction(class_provider.register):
|
|
352
|
-
Coroutine(class_provider.register).run()
|
|
353
|
-
else:
|
|
354
|
-
class_provider.register()
|
|
353
|
+
# Retrieve the 'register' method if it exists
|
|
354
|
+
register_method = getattr(provider_instance, 'register', None)
|
|
355
355
|
|
|
356
|
-
#
|
|
357
|
-
|
|
356
|
+
# If the register method exists, call it
|
|
357
|
+
if callable(register_method):
|
|
358
358
|
|
|
359
|
-
|
|
359
|
+
# If the register method is a coroutine, run it asynchronously
|
|
360
|
+
if asyncio.iscoroutinefunction(register_method):
|
|
361
|
+
asyncio.run(register_method())
|
|
362
|
+
|
|
363
|
+
# Otherwise, call it synchronously
|
|
364
|
+
else:
|
|
365
|
+
register_method()
|
|
366
|
+
|
|
367
|
+
# Add the initialized provider instance to the list
|
|
368
|
+
initialized_providers.append(provider_instance)
|
|
369
|
+
|
|
370
|
+
# Replace the providers list with the list of initialized provider instances
|
|
360
371
|
self.__providers = initialized_providers
|
|
361
372
|
|
|
362
373
|
def __bootProviders(
|
|
363
374
|
self
|
|
364
375
|
) -> None:
|
|
365
376
|
"""
|
|
366
|
-
|
|
377
|
+
Boot all registered service providers after registration.
|
|
378
|
+
|
|
379
|
+
This private method iterates through all instantiated service providers and calls their
|
|
380
|
+
`boot()` method to perform any post-registration initialization. This two-phase approach
|
|
381
|
+
ensures that all dependencies are registered before any provider attempts to use them.
|
|
382
|
+
Both synchronous and asynchronous `boot()` methods are supported.
|
|
367
383
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
two-phase process ensures all dependencies are available before any
|
|
371
|
-
provider attempts to use them. Supports both synchronous and asynchronous
|
|
372
|
-
boot methods.
|
|
384
|
+
After all providers have been booted, the internal providers list is cleared to free memory,
|
|
385
|
+
as provider instances are no longer needed after initialization.
|
|
373
386
|
|
|
374
387
|
Notes
|
|
375
388
|
-----
|
|
376
|
-
This is
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
after
|
|
389
|
+
- This method is called automatically during application bootstrapping, after all providers
|
|
390
|
+
have been registered.
|
|
391
|
+
- Supports both synchronous and asynchronous `boot()` methods on providers.
|
|
392
|
+
- The providers list is cleared after booting to prevent memory leaks.
|
|
393
|
+
|
|
394
|
+
Returns
|
|
395
|
+
-------
|
|
396
|
+
None
|
|
397
|
+
This method does not return any value.
|
|
380
398
|
"""
|
|
381
399
|
|
|
382
|
-
# Iterate over each provider and boot
|
|
400
|
+
# Iterate over each initialized provider and call its boot method if available
|
|
383
401
|
for provider in self.__providers:
|
|
384
402
|
|
|
385
|
-
#
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
403
|
+
# Get the boot method if it exists
|
|
404
|
+
boot_method = getattr(provider, 'boot', None)
|
|
405
|
+
|
|
406
|
+
if callable(boot_method):
|
|
407
|
+
|
|
408
|
+
# If the boot method is a coroutine, run it asynchronously
|
|
409
|
+
if asyncio.iscoroutinefunction(boot_method):
|
|
410
|
+
asyncio.run(boot_method())
|
|
411
|
+
|
|
412
|
+
# Otherwise, call it synchronously
|
|
390
413
|
else:
|
|
391
|
-
|
|
414
|
+
boot_method()
|
|
392
415
|
|
|
393
|
-
#
|
|
394
|
-
|
|
395
|
-
del self.__providers
|
|
416
|
+
# Clear the providers list to free memory after booting is complete
|
|
417
|
+
self.__providers.clear()
|
|
396
418
|
|
|
397
419
|
# === Application Skeleton Configuration Methods ===
|
|
398
420
|
# The Orionis framework provides methods to configure each component of the application,
|
|
@@ -1,11 +1,58 @@
|
|
|
1
1
|
class OrionisIntegrityException(Exception):
|
|
2
|
-
|
|
2
|
+
"""
|
|
3
|
+
Exception raised for integrity-related errors in the Orionis framework.
|
|
4
|
+
|
|
5
|
+
This exception is intended to signal violations of data integrity or
|
|
6
|
+
consistency constraints within the application.
|
|
7
|
+
|
|
8
|
+
Returns
|
|
9
|
+
-------
|
|
10
|
+
OrionisIntegrityException
|
|
11
|
+
An instance of the exception.
|
|
12
|
+
"""
|
|
13
|
+
pass # No additional logic; inherits from base Exception
|
|
14
|
+
|
|
3
15
|
|
|
4
16
|
class OrionisRuntimeError(RuntimeError):
|
|
5
|
-
|
|
17
|
+
"""
|
|
18
|
+
Exception raised for runtime errors specific to the Orionis framework.
|
|
19
|
+
|
|
20
|
+
This exception should be used when an error occurs that is only detectable
|
|
21
|
+
during program execution.
|
|
22
|
+
|
|
23
|
+
Returns
|
|
24
|
+
-------
|
|
25
|
+
OrionisRuntimeError
|
|
26
|
+
An instance of the exception.
|
|
27
|
+
"""
|
|
28
|
+
pass # Inherits from Python's built-in RuntimeError
|
|
29
|
+
|
|
6
30
|
|
|
7
31
|
class OrionisTypeError(TypeError):
|
|
8
|
-
|
|
32
|
+
"""
|
|
33
|
+
Exception raised for type errors in the Orionis framework.
|
|
34
|
+
|
|
35
|
+
This exception is used when an operation or function receives an argument
|
|
36
|
+
of an inappropriate type.
|
|
37
|
+
|
|
38
|
+
Returns
|
|
39
|
+
-------
|
|
40
|
+
OrionisTypeError
|
|
41
|
+
An instance of the exception.
|
|
42
|
+
"""
|
|
43
|
+
pass # Inherits from Python's built-in TypeError
|
|
44
|
+
|
|
9
45
|
|
|
10
46
|
class OrionisValueError(ValueError):
|
|
11
|
-
|
|
47
|
+
"""
|
|
48
|
+
Exception raised for value errors in the Orionis framework.
|
|
49
|
+
|
|
50
|
+
This exception is used when an operation or function receives an argument
|
|
51
|
+
with the right type but an inappropriate value.
|
|
52
|
+
|
|
53
|
+
Returns
|
|
54
|
+
-------
|
|
55
|
+
OrionisValueError
|
|
56
|
+
An instance of the exception.
|
|
57
|
+
"""
|
|
58
|
+
pass # Inherits from Python's built-in ValueError
|
|
@@ -3,47 +3,26 @@ from orionis.failure.catch import Catch
|
|
|
3
3
|
from orionis.failure.contracts.catch import ICatch
|
|
4
4
|
|
|
5
5
|
class CathcProvider(ServiceProvider):
|
|
6
|
-
"""
|
|
7
|
-
Provides and registers the Catch service within the application container.
|
|
8
|
-
|
|
9
|
-
This service provider is responsible for binding the ICatch interface to its concrete
|
|
10
|
-
implementation, Catch, as a singleton. By doing so, it ensures that a single shared
|
|
11
|
-
instance of Catch is available for dependency injection throughout the application.
|
|
12
|
-
|
|
13
|
-
Returns
|
|
14
|
-
-------
|
|
15
|
-
None
|
|
16
|
-
This class does not return a value; it is used for service registration.
|
|
17
|
-
"""
|
|
18
6
|
|
|
19
7
|
def register(self) -> None:
|
|
20
8
|
"""
|
|
21
|
-
|
|
9
|
+
Registers the Catch service as a singleton in the application container.
|
|
22
10
|
|
|
23
|
-
This method binds the ICatch interface to the Catch implementation
|
|
24
|
-
|
|
11
|
+
This method binds the `ICatch` interface to the `Catch` implementation as a singleton,
|
|
12
|
+
using a specific alias. This ensures that only one instance of `Catch` is created and
|
|
13
|
+
shared throughout the application's lifecycle. The binding allows the application to
|
|
14
|
+
resolve dependencies on `ICatch` with the registered `Catch` instance.
|
|
25
15
|
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
Parameters
|
|
17
|
+
----------
|
|
28
18
|
None
|
|
29
|
-
This method does not return any value.
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
# Bind ICatch to Catch as a singleton with a specific alias
|
|
33
|
-
self.app.singleton(ICatch, Catch, alias=f"x-{ICatch.__module__}.{ICatch.__name__}")
|
|
34
|
-
|
|
35
|
-
def boot(self) -> None:
|
|
36
|
-
"""
|
|
37
|
-
Perform any actions required after all providers have been registered.
|
|
38
|
-
|
|
39
|
-
This method is called after the register phase and can be used to perform
|
|
40
|
-
additional initialization if needed.
|
|
41
19
|
|
|
42
20
|
Returns
|
|
43
21
|
-------
|
|
44
22
|
None
|
|
45
|
-
This method does not return any value.
|
|
23
|
+
This method does not return any value. It performs the registration as a side effect.
|
|
46
24
|
"""
|
|
47
25
|
|
|
48
|
-
#
|
|
49
|
-
|
|
26
|
+
# Register the Catch implementation as a singleton for the ICatch interface
|
|
27
|
+
# The alias allows for explicit resolution by name if needed
|
|
28
|
+
self.app.singleton(ICatch, Catch, alias="x-orionis.failure.contracts.catch.ICatch")
|
|
@@ -3,42 +3,27 @@ from orionis.console.request.cli_request import CLIRequest
|
|
|
3
3
|
from orionis.container.providers.service_provider import ServiceProvider
|
|
4
4
|
|
|
5
5
|
class CLRequestProvider(ServiceProvider):
|
|
6
|
-
"""
|
|
7
|
-
Service provider for registering CLI request services in the Orionis framework.
|
|
8
|
-
|
|
9
|
-
This provider handles the registration and binding of CLI request interfaces
|
|
10
|
-
to their concrete implementations within the application container.
|
|
11
|
-
"""
|
|
12
6
|
|
|
13
7
|
def register(self) -> None:
|
|
14
8
|
"""
|
|
15
|
-
|
|
9
|
+
Registers the CLI request services in the application container.
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
transient service
|
|
19
|
-
|
|
11
|
+
This method binds the `ICLIRequest` interface to the `CLIRequest` implementation
|
|
12
|
+
as a transient service within the application's dependency injection container.
|
|
13
|
+
By registering this binding, any component that depends on `ICLIRequest` will
|
|
14
|
+
receive a new instance of `CLIRequest` each time it is resolved. The binding is
|
|
15
|
+
also associated with a specific alias for reference within the container.
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
Parameters
|
|
18
|
+
----------
|
|
23
19
|
None
|
|
24
|
-
This method does not return any value.
|
|
25
|
-
"""
|
|
26
|
-
# Register CLIRequest as a transient service bound to ICLIRequest interface
|
|
27
|
-
# Transient services create a new instance each time they are resolved
|
|
28
|
-
self.app.transient(ICLIRequest, CLIRequest, alias=f"x-{ICLIRequest.__module__}.{ICLIRequest.__name__}")
|
|
29
|
-
|
|
30
|
-
def boot(self) -> None:
|
|
31
|
-
"""
|
|
32
|
-
Perform any necessary bootstrapping after service registration.
|
|
33
|
-
|
|
34
|
-
This method is called after all services have been registered and can be
|
|
35
|
-
used to perform additional setup or configuration tasks. Currently, no
|
|
36
|
-
bootstrapping logic is required for CLI request services.
|
|
37
20
|
|
|
38
21
|
Returns
|
|
39
22
|
-------
|
|
40
23
|
None
|
|
41
|
-
This method does not return any value.
|
|
24
|
+
This method does not return any value. It performs registration as a side effect.
|
|
42
25
|
"""
|
|
43
|
-
|
|
44
|
-
|
|
26
|
+
|
|
27
|
+
# Bind the ICLIRequest interface to the CLIRequest implementation as a transient service.
|
|
28
|
+
# Each resolution of ICLIRequest will provide a new CLIRequest instance.
|
|
29
|
+
self.app.transient(ICLIRequest, CLIRequest, alias="x-orionis.console.contracts.cli_request.ICLIRequest")
|
|
@@ -3,63 +3,29 @@ from orionis.console.contracts.console import IConsole
|
|
|
3
3
|
from orionis.container.providers.service_provider import ServiceProvider
|
|
4
4
|
|
|
5
5
|
class ConsoleProvider(ServiceProvider):
|
|
6
|
-
"""
|
|
7
|
-
Console output service provider for the Orionis framework.
|
|
8
|
-
|
|
9
|
-
This service provider is responsible for registering and configuring the console
|
|
10
|
-
output service within the application's dependency injection container. It binds
|
|
11
|
-
the IConsole interface to its concrete Console implementation, enabling the
|
|
12
|
-
application to access comprehensive console output functionality including
|
|
13
|
-
informational messages, warnings, errors, debug output, tabular data display,
|
|
14
|
-
user confirmations, and secure password input prompts.
|
|
15
|
-
|
|
16
|
-
The provider follows the standard service provider pattern, implementing both
|
|
17
|
-
registration and boot phases for proper initialization within the application
|
|
18
|
-
lifecycle.
|
|
19
|
-
"""
|
|
20
6
|
|
|
21
7
|
def register(self) -> None:
|
|
22
8
|
"""
|
|
23
|
-
|
|
9
|
+
Registers the console output service within the application's dependency injection container.
|
|
24
10
|
|
|
25
|
-
This method binds the IConsole interface to its concrete Console implementation,
|
|
26
|
-
|
|
27
|
-
service is registered as a transient dependency,
|
|
28
|
-
|
|
11
|
+
This method binds the `IConsole` interface to its concrete `Console` implementation,
|
|
12
|
+
enabling console output functionality to be injected wherever required in the application.
|
|
13
|
+
The service is registered as a transient dependency, ensuring that a new instance of
|
|
14
|
+
`Console` is created each time the service is resolved from the container. The registration
|
|
15
|
+
uses a predefined alias to maintain consistent service identification and facilitate
|
|
16
|
+
straightforward service resolution throughout the framework.
|
|
29
17
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Returns
|
|
34
|
-
-------
|
|
18
|
+
Parameters
|
|
19
|
+
----------
|
|
35
20
|
None
|
|
36
|
-
This method does not return any value. It performs side effects by
|
|
37
|
-
modifying the application's service container.
|
|
38
|
-
"""
|
|
39
|
-
|
|
40
|
-
self.app.transient(IConsole, Console, alias=f"x-{IConsole.__module__}.{IConsole.__name__}")
|
|
41
|
-
|
|
42
|
-
def boot(self) -> None:
|
|
43
|
-
"""
|
|
44
|
-
Perform post-registration initialization for the console provider.
|
|
45
|
-
|
|
46
|
-
This method is called after the registration phase is complete and all services
|
|
47
|
-
have been registered in the container. It provides an opportunity to perform
|
|
48
|
-
any additional setup, configuration, or initialization that depends on other
|
|
49
|
-
services being available in the container.
|
|
50
|
-
|
|
51
|
-
Currently, this implementation serves as a placeholder and does not perform
|
|
52
|
-
any specific initialization tasks. The console service is fully functional
|
|
53
|
-
after registration and does not require additional boot-time configuration.
|
|
54
|
-
|
|
55
|
-
This method is part of the service provider lifecycle and is automatically
|
|
56
|
-
invoked by the framework during application startup.
|
|
57
21
|
|
|
58
22
|
Returns
|
|
59
23
|
-------
|
|
60
24
|
None
|
|
61
|
-
This method does not return any value
|
|
62
|
-
|
|
25
|
+
This method does not return any value. It performs side effects by
|
|
26
|
+
modifying the application's service container to register the console service.
|
|
63
27
|
"""
|
|
64
28
|
|
|
65
|
-
|
|
29
|
+
# Register the IConsole interface to the Console implementation as a transient service.
|
|
30
|
+
# This ensures a new Console instance is provided on each resolution.
|
|
31
|
+
self.app.transient(IConsole, Console, alias="x-orionis.console.contracts.console.IConsole")
|
|
@@ -3,53 +3,27 @@ from orionis.services.file.contracts.directory import IDirectory
|
|
|
3
3
|
from orionis.services.file.directory import Directory
|
|
4
4
|
|
|
5
5
|
class DirectoryProvider(ServiceProvider):
|
|
6
|
-
"""
|
|
7
|
-
Service provider for registering the directory service in the application container.
|
|
8
|
-
|
|
9
|
-
This provider binds the `IDirectory` interface to its concrete implementation (`Directory`)
|
|
10
|
-
as a singleton. This ensures that a single shared instance of the directory service is
|
|
11
|
-
available for dependency injection throughout the application.
|
|
12
|
-
|
|
13
|
-
Attributes
|
|
14
|
-
----------
|
|
15
|
-
app : Application
|
|
16
|
-
The application container instance where services are registered.
|
|
17
|
-
|
|
18
|
-
Methods
|
|
19
|
-
-------
|
|
20
|
-
register()
|
|
21
|
-
Registers the directory service as a singleton in the application container.
|
|
22
|
-
boot()
|
|
23
|
-
Performs post-registration actions if necessary.
|
|
24
|
-
"""
|
|
25
6
|
|
|
26
7
|
def register(self) -> None:
|
|
27
8
|
"""
|
|
28
|
-
|
|
9
|
+
Registers the directory service as a singleton within the application container.
|
|
29
10
|
|
|
30
|
-
This method binds the `IDirectory` interface to
|
|
31
|
-
a
|
|
32
|
-
|
|
11
|
+
This method binds the `IDirectory` interface to its concrete implementation `Directory`
|
|
12
|
+
as a singleton. The binding is associated with a specific alias, ensuring that only one
|
|
13
|
+
instance of `Directory` is created and shared across the application's lifecycle. This
|
|
14
|
+
promotes efficient resource usage and consistent behavior when accessing directory-related
|
|
15
|
+
services.
|
|
33
16
|
|
|
34
|
-
|
|
35
|
-
|
|
17
|
+
Parameters
|
|
18
|
+
----------
|
|
36
19
|
None
|
|
37
|
-
This method does not return any value.
|
|
38
|
-
"""
|
|
39
|
-
# Bind IDirectory to Directory as a singleton with a specific alias
|
|
40
|
-
self.app.singleton(IDirectory, Directory, alias=f"x-{IDirectory.__module__}.{IDirectory.__name__}")
|
|
41
|
-
|
|
42
|
-
def boot(self) -> None:
|
|
43
|
-
"""
|
|
44
|
-
Perform actions required after all providers have been registered.
|
|
45
|
-
|
|
46
|
-
This method is called after the `register` phase. It can be used for additional
|
|
47
|
-
initialization if needed. No additional boot logic is required for this provider.
|
|
48
20
|
|
|
49
21
|
Returns
|
|
50
22
|
-------
|
|
51
23
|
None
|
|
52
|
-
This method does not return any value.
|
|
24
|
+
This method does not return any value. It performs registration as a side effect.
|
|
53
25
|
"""
|
|
54
|
-
|
|
55
|
-
|
|
26
|
+
|
|
27
|
+
# Bind the IDirectory interface to the Directory implementation as a singleton.
|
|
28
|
+
# The alias ensures unique identification within the container.
|
|
29
|
+
self.app.singleton(IDirectory, Directory, alias="x-orionis.services.file.contracts.directory.IDirectory")
|
|
@@ -3,77 +3,27 @@ from orionis.console.contracts.debug import IDebug
|
|
|
3
3
|
from orionis.container.providers.service_provider import ServiceProvider
|
|
4
4
|
|
|
5
5
|
class DumperProvider(ServiceProvider):
|
|
6
|
-
"""
|
|
7
|
-
Service provider for registering debug and dumper services in the application container.
|
|
8
|
-
|
|
9
|
-
This provider is responsible for binding debug-related interfaces to their concrete
|
|
10
|
-
implementations within the application's dependency injection container. It enables
|
|
11
|
-
comprehensive debug message printing, error reporting, console diagnostics, and
|
|
12
|
-
data dumping functionality throughout the application.
|
|
13
|
-
|
|
14
|
-
The provider follows the service provider pattern, ensuring that debug services
|
|
15
|
-
are properly registered and available for dependency injection across all
|
|
16
|
-
application components that require debugging capabilities.
|
|
17
|
-
|
|
18
|
-
Attributes
|
|
19
|
-
----------
|
|
20
|
-
app : Application
|
|
21
|
-
The application container instance used for service registration and
|
|
22
|
-
dependency injection management.
|
|
23
|
-
|
|
24
|
-
Methods
|
|
25
|
-
-------
|
|
26
|
-
register() -> None
|
|
27
|
-
Register the debug service interface binding in the application container.
|
|
28
|
-
boot() -> None
|
|
29
|
-
Perform any post-registration initialization tasks for the dumper services.
|
|
30
|
-
|
|
31
|
-
Notes
|
|
32
|
-
-----
|
|
33
|
-
This provider registers services as transient, meaning new instances are created
|
|
34
|
-
for each resolution request, ensuring isolated debugging contexts.
|
|
35
|
-
"""
|
|
36
6
|
|
|
37
7
|
def register(self) -> None:
|
|
38
8
|
"""
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
This method binds the IDebug interface to its concrete implementation (Debug class)
|
|
42
|
-
in the application's dependency injection container. The service is registered as
|
|
43
|
-
transient, meaning a new instance will be created each time it is requested.
|
|
44
|
-
The service is also assigned an alias for easy retrieval throughout the application.
|
|
45
|
-
|
|
46
|
-
The registration enables the application to resolve debug-related dependencies
|
|
47
|
-
and provides access to debugging, error reporting, and console diagnostic
|
|
48
|
-
functionality via the registered alias.
|
|
49
|
-
|
|
50
|
-
Returns
|
|
51
|
-
-------
|
|
52
|
-
None
|
|
53
|
-
This method does not return any value. It performs side effects by
|
|
54
|
-
modifying the application container's service registry.
|
|
55
|
-
"""
|
|
56
|
-
|
|
57
|
-
self.app.transient(IDebug, Debug, alias=f"x-{IDebug.__module__}.{IDebug.__name__}")
|
|
58
|
-
|
|
59
|
-
def boot(self) -> None:
|
|
60
|
-
"""
|
|
61
|
-
Perform post-registration initialization for the dumper service provider.
|
|
9
|
+
Registers the debug service in the application container.
|
|
62
10
|
|
|
63
|
-
This method
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
11
|
+
This method binds the `IDebug` interface to its concrete implementation, the `Debug` class,
|
|
12
|
+
within the application's dependency injection container. The service is registered as
|
|
13
|
+
transient, ensuring that a new instance is created each time it is requested. Additionally,
|
|
14
|
+
an alias is assigned to the service for convenient retrieval throughout the application.
|
|
67
15
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
registration is sufficient and complete during the register() phase.
|
|
16
|
+
This registration enables the application to resolve dependencies related to debugging,
|
|
17
|
+
error reporting, and console diagnostics by referencing the interface or its alias.
|
|
71
18
|
|
|
72
19
|
Returns
|
|
73
20
|
-------
|
|
74
21
|
None
|
|
75
|
-
This method does not return any value
|
|
76
|
-
|
|
22
|
+
This method does not return any value. It performs side effects by modifying
|
|
23
|
+
the application's service registry.
|
|
77
24
|
"""
|
|
78
25
|
|
|
79
|
-
|
|
26
|
+
# Register the Debug service as a transient binding for the IDebug interface.
|
|
27
|
+
# A new instance of Debug will be created each time it is requested.
|
|
28
|
+
# The alias allows for easy retrieval of the service elsewhere in the application.
|
|
29
|
+
self.app.transient(IDebug, Debug, alias=f"x-orionis.console.contracts.debug.IDebug")
|