cpl.dependency_injection¶
cpl.dependency_injection.service_collection¶
- 
class 
cpl.dependency_injection.service_collection.ServiceCollection(config: cpl.configuration.configuration_abc.ConfigurationABC)¶ Bases:
cpl.dependency_injection.service_collection_abc.ServiceCollectionABCRepresentation of the collection of services
- 
add_db_context(db_context_type: Type[cpl.database.context.database_context_abc.DatabaseContextABC], db_settings: cpl.database.database_settings.DatabaseSettings)¶ Adds database context
- db_context: Type[
cpl.database.context.database_context_abc.DatabaseContextABC] Database context
- db_settings: 
cpl.database.database_settings.DatabaseSettings Database settings
- db_context: Type[
 
- 
add_logging()¶ Adds the CPL internal logger
- 
add_scoped(service_type: Type, service: Optional[Callable] = None)¶ Adds a service with scoped lifetime
- service_type: 
Type Type of the service
- service: 
Callable Object of the service
- service_type: 
 
- 
add_singleton(service_type: Union[type, object], service: Optional[Union[type, object]] = None)¶ Adds a service with singleton lifetime
- service_type: 
Type Type of the service
- service: 
Callable Object of the service
- service_type: 
 
- 
add_transient(service_type: type, service: Optional[type] = None)¶ Adds a service with transient lifetime
- service_type: 
Type Type of the service
- service: 
Callable Object of the service
- service_type: 
 
- 
build_service_provider() → cpl.dependency_injection.service_provider_abc.ServiceProviderABC¶ Creates instance of the service provider
- 
 
cpl.dependency_injection.service_collection_abc¶
- 
class 
cpl.dependency_injection.service_collection_abc.ServiceCollectionABC¶ Bases:
abc.ABCABC for the class
cpl.dependency_injection.service_collection.ServiceCollection- 
abstract 
add_db_context(db_context: Type[cpl.database.context.database_context_abc.DatabaseContextABC], db_settings: cpl.database.database_settings.DatabaseSettings)¶ Adds database context
- db_context: Type[
cpl.database.context.database_context_abc.DatabaseContextABC] Database context
- db_settings: 
cpl.database.database_settings.DatabaseSettings Database settings
- db_context: Type[
 
- 
abstract 
add_logging()¶ Adds the CPL internal logger
- 
abstract 
add_scoped(service_type: Type, service: Optional[collections.abc.Callable] = None)¶ Adds a service with scoped lifetime
- service_type: 
Type Type of the service
- service: 
Callable Object of the service
- service_type: 
 
- 
abstract 
add_singleton(service_type: Type, service: Optional[collections.abc.Callable] = None)¶ Adds a service with singleton lifetime
- service_type: 
Type Type of the service
- service: 
Callable Object of the service
- service_type: 
 
- 
abstract 
add_transient(service_type: Type, service: Optional[collections.abc.Callable] = None)¶ Adds a service with transient lifetime
- service_type: 
Type Type of the service
- service: 
Callable Object of the service
- service_type: 
 
- 
abstract 
build_service_provider() → cpl.dependency_injection.service_provider_abc.ServiceProviderABC¶ Creates instance of the service provider
- 
abstract 
 
cpl.dependency_injection.service_descriptor¶
- 
class 
cpl.dependency_injection.service_descriptor.ServiceDescriptor(implementation: Optional[Union[type, object]], lifetime: cpl.dependency_injection.service_lifetime_enum.ServiceLifetimeEnum)¶ Bases:
objectDescriptor of a service
- implementation: Union[
type, Optional[object]] Object or type of service
- lifetime: 
cpl.dependency_injection.service_lifetime_enum.ServiceLifetimeEnum Lifetime of the service
- 
property 
implementation¶ 
- 
property 
lifetime¶ 
- 
property 
service_type¶ 
- implementation: Union[
 
cpl.dependency_injection.service_lifetime_enum¶
cpl.dependency_injection.service_provider¶
- 
class 
cpl.dependency_injection.service_provider.ServiceProvider(service_descriptors: list, config: cpl.configuration.configuration_abc.ConfigurationABC, db_context: Optional[cpl.database.context.database_context_abc.DatabaseContextABC])¶ Bases:
cpl.dependency_injection.service_provider_abc.ServiceProviderABCProvider for the services
- service_descriptors: list[
cpl.dependency_injection.service_descriptor.ServiceDescriptor] Descriptor of the service
- config: 
cpl.configuration.configuration_abc.ConfigurationABC CPL Configuration
- db_context: Optional[
cpl.database.context.database_context_abc.DatabaseContextABC] Database representation
- 
build_service(service_type: type) → object¶ Creates instance of given type
- instance_type: 
Type The type of the searched instance
Object of the given type
- instance_type: 
 
- 
get_service(service_type: type) → Optional[collections.abc.Callable[object]]¶ Returns instance of given type
- instance_type: 
Type The type of the searched instance
Object of type Optional[Callable[
object]]- instance_type: 
 
- service_descriptors: list[
 
cpl.dependency_injection.service_provider_abc¶
- 
class 
cpl.dependency_injection.service_provider_abc.ServiceProviderABC¶ Bases:
abc.ABCABC for the class
cpl.dependency_injection.service_provider.ServiceProvider- 
abstract 
build_service(service_type: Type) → object¶ Creates instance of given type
- instance_type: 
Type The type of the searched instance
Object of the given type
- instance_type: 
 
- 
abstract 
get_service(instance_type: Type) → Optional[collections.abc.Callable[object]]¶ Returns instance of given type
- instance_type: 
Type The type of the searched instance
Object of type Optional[Callable[
object]]- instance_type: 
 
- 
abstract