orionis 0.613.0__py3-none-any.whl → 0.615.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 +100 -61
- 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.613.0.dist-info → orionis-0.615.0.dist-info}/METADATA +1 -1
- {orionis-0.613.0.dist-info → orionis-0.615.0.dist-info}/RECORD +35 -36
- orionis/foundation/contracts/config.py +0 -31
- {orionis-0.613.0.dist-info → orionis-0.615.0.dist-info}/WHEEL +0 -0
- {orionis-0.613.0.dist-info → orionis-0.615.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.613.0.dist-info → orionis-0.615.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,30 +23,46 @@ 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
|
|
|
30
29
|
class Application(Container, IApplication):
|
|
31
30
|
"""
|
|
32
|
-
Main
|
|
33
|
-
|
|
34
|
-
This class extends the
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
Application: Main container that manages the complete lifecycle of the Orionis application.
|
|
32
|
+
|
|
33
|
+
This class extends `Container` and acts as the central core of the Orionis framework,
|
|
34
|
+
orchestrating initialization, configuration, registration, and bootstrapping of all
|
|
35
|
+
application components and services. It follows a fluent interface pattern, enabling
|
|
36
|
+
method chaining for clear and concise configuration.
|
|
37
|
+
|
|
38
|
+
Key Responsibilities:
|
|
39
|
+
---------------------
|
|
40
|
+
- Registers and boots both native and user-defined service providers, ensuring all
|
|
41
|
+
dependencies and services are available throughout the application lifecycle.
|
|
42
|
+
- Loads and manages essential framework kernels (CLI, testing, etc.), guaranteeing
|
|
43
|
+
that core components are properly initialized and accessible.
|
|
44
|
+
- Centralizes configuration management for all critical subsystems: authentication,
|
|
45
|
+
cache, database, logging, mail, queue, routing, storage, session, testing, and more.
|
|
46
|
+
- Provides methods for customizing and extending the application architecture,
|
|
47
|
+
supporting dynamic configurator loading and seamless integration of additional services.
|
|
48
|
+
- Implements mechanisms for custom exception handling and schedulers, enhancing
|
|
49
|
+
robustness and flexibility across the application lifecycle.
|
|
50
|
+
- Exposes utilities for accessing configuration and path settings using dot notation.
|
|
51
|
+
|
|
52
|
+
Typical Workflow:
|
|
53
|
+
-----------------
|
|
54
|
+
1. Instantiate the Application class.
|
|
55
|
+
2. Register providers and configurators via `withProviders` and `withConfigurators`.
|
|
56
|
+
3. Optionally customize exception handlers and schedulers.
|
|
57
|
+
4. Call `create()` to initialize and boot the application, loading kernels and providers.
|
|
58
|
+
5. Access services, configuration, and paths through the Application instance.
|
|
43
59
|
|
|
44
60
|
Attributes
|
|
45
61
|
----------
|
|
46
62
|
isBooted : bool
|
|
47
|
-
|
|
63
|
+
Read-only property indicating whether the application providers have been booted.
|
|
48
64
|
startAt : int
|
|
49
|
-
|
|
65
|
+
Read-only property containing the timestamp (epoch) when the application was started.
|
|
50
66
|
"""
|
|
51
67
|
|
|
52
68
|
@property
|
|
@@ -162,11 +178,7 @@ class Application(Container, IApplication):
|
|
|
162
178
|
|
|
163
179
|
# Register each kernel instance
|
|
164
180
|
for abstract, concrete in core_kernels.items():
|
|
165
|
-
self.instance(
|
|
166
|
-
abstract,
|
|
167
|
-
concrete(self),
|
|
168
|
-
alias=f"x-{abstract.__module__}.{abstract.__name__}"
|
|
169
|
-
)
|
|
181
|
+
self.instance(abstract, concrete(self), alias=f"x-{abstract.__module__}.{abstract.__name__}")
|
|
170
182
|
|
|
171
183
|
def __loadFrameworkProviders(
|
|
172
184
|
self
|
|
@@ -324,75 +336,102 @@ class Application(Container, IApplication):
|
|
|
324
336
|
"""
|
|
325
337
|
Instantiate and register all service providers in the container.
|
|
326
338
|
|
|
327
|
-
This method iterates through all
|
|
328
|
-
with the current application instance, and
|
|
329
|
-
to bind services into the dependency injection container.
|
|
330
|
-
|
|
339
|
+
This private method iterates through all service provider classes previously added to the application,
|
|
340
|
+
instantiates each provider with the current application instance, and invokes their `register()` method
|
|
341
|
+
to bind services into the dependency injection container. Both synchronous and asynchronous `register()`
|
|
342
|
+
methods are supported and handled appropriately.
|
|
343
|
+
|
|
344
|
+
After registration, the internal providers list is updated to contain the instantiated provider objects
|
|
345
|
+
instead of class references. This ensures that subsequent booting operations are performed on the actual
|
|
346
|
+
provider instances.
|
|
331
347
|
|
|
332
348
|
Notes
|
|
333
349
|
-----
|
|
334
|
-
This is
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
350
|
+
- This method is called automatically during application bootstrapping.
|
|
351
|
+
- Handles both coroutine and regular `register()` methods using `asyncio` when necessary.
|
|
352
|
+
- The providers list is updated in-place to hold provider instances.
|
|
353
|
+
|
|
354
|
+
Returns
|
|
355
|
+
-------
|
|
356
|
+
None
|
|
357
|
+
This method does not return any value. It updates the internal state of the application by
|
|
358
|
+
replacing the provider class references with their instantiated objects.
|
|
338
359
|
"""
|
|
339
360
|
|
|
340
|
-
#
|
|
361
|
+
# Prepare a list to hold initialized provider instances
|
|
341
362
|
initialized_providers = []
|
|
342
363
|
|
|
343
|
-
# Iterate over each provider
|
|
344
|
-
for
|
|
364
|
+
# Iterate over each provider class in the providers list
|
|
365
|
+
for provider_cls in self.__providers:
|
|
345
366
|
|
|
346
|
-
#
|
|
347
|
-
|
|
367
|
+
# Instantiate the provider with the current application instance
|
|
368
|
+
provider_instance = provider_cls(self)
|
|
348
369
|
|
|
349
|
-
#
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
class_provider.register()
|
|
370
|
+
# Retrieve the 'register' method if it exists
|
|
371
|
+
register_method = getattr(provider_instance, 'register', None)
|
|
372
|
+
|
|
373
|
+
# If the register method exists, call it
|
|
374
|
+
if callable(register_method):
|
|
355
375
|
|
|
356
|
-
|
|
357
|
-
|
|
376
|
+
# If the register method is a coroutine, run it asynchronously
|
|
377
|
+
if asyncio.iscoroutinefunction(register_method):
|
|
378
|
+
asyncio.run(register_method())
|
|
358
379
|
|
|
359
|
-
|
|
380
|
+
# Otherwise, call it synchronously
|
|
381
|
+
else:
|
|
382
|
+
register_method()
|
|
383
|
+
|
|
384
|
+
# Add the initialized provider instance to the list
|
|
385
|
+
initialized_providers.append(provider_instance)
|
|
386
|
+
|
|
387
|
+
# Replace the providers list with the list of initialized provider instances
|
|
360
388
|
self.__providers = initialized_providers
|
|
361
389
|
|
|
362
390
|
def __bootProviders(
|
|
363
391
|
self
|
|
364
392
|
) -> None:
|
|
365
393
|
"""
|
|
366
|
-
|
|
394
|
+
Boot all registered service providers after registration.
|
|
367
395
|
|
|
368
|
-
This method
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
396
|
+
This private method iterates through all instantiated service providers and calls their
|
|
397
|
+
`boot()` method to perform any post-registration initialization. This two-phase approach
|
|
398
|
+
ensures that all dependencies are registered before any provider attempts to use them.
|
|
399
|
+
Both synchronous and asynchronous `boot()` methods are supported.
|
|
400
|
+
|
|
401
|
+
After all providers have been booted, the internal providers list is cleared to free memory,
|
|
402
|
+
as provider instances are no longer needed after initialization.
|
|
373
403
|
|
|
374
404
|
Notes
|
|
375
405
|
-----
|
|
376
|
-
This is
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
after
|
|
406
|
+
- This method is called automatically during application bootstrapping, after all providers
|
|
407
|
+
have been registered.
|
|
408
|
+
- Supports both synchronous and asynchronous `boot()` methods on providers.
|
|
409
|
+
- The providers list is cleared after booting to prevent memory leaks.
|
|
410
|
+
|
|
411
|
+
Returns
|
|
412
|
+
-------
|
|
413
|
+
None
|
|
414
|
+
This method does not return any value.
|
|
380
415
|
"""
|
|
381
416
|
|
|
382
|
-
# Iterate over each provider and boot
|
|
417
|
+
# Iterate over each initialized provider and call its boot method if available
|
|
383
418
|
for provider in self.__providers:
|
|
384
419
|
|
|
385
|
-
#
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
420
|
+
# Get the boot method if it exists
|
|
421
|
+
boot_method = getattr(provider, 'boot', None)
|
|
422
|
+
|
|
423
|
+
if callable(boot_method):
|
|
424
|
+
|
|
425
|
+
# If the boot method is a coroutine, run it asynchronously
|
|
426
|
+
if asyncio.iscoroutinefunction(boot_method):
|
|
427
|
+
asyncio.run(boot_method())
|
|
428
|
+
|
|
429
|
+
# Otherwise, call it synchronously
|
|
390
430
|
else:
|
|
391
|
-
|
|
431
|
+
boot_method()
|
|
392
432
|
|
|
393
|
-
#
|
|
394
|
-
|
|
395
|
-
del self.__providers
|
|
433
|
+
# Clear the providers list to free memory after booting is complete
|
|
434
|
+
self.__providers.clear()
|
|
396
435
|
|
|
397
436
|
# === Application Skeleton Configuration Methods ===
|
|
398
437
|
# 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")
|