harp.services.models¶
- class BaseServiceDefinitionCollection[source]¶
Bases:
BaseModelBase class for coherent sequences of services. The traverse() method can be used to get a flat iterator over all the service definitions in the collection and its children, ordered.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- services: Sequence[Annotated[Annotated[ServiceDefinition, Tag(tag=service)] | Annotated[BaseServiceDefinitionCollection, Tag(tag=collection)] | Annotated[ConditionalServiceDefinitionCollection, Tag(tag=conditional_collection)], Discriminator(discriminator=_discriminator, custom_error_type=None, custom_error_message=None, custom_error_context=None)]]¶
- class ConditionalServiceDefinitionCollection[source]¶
Bases:
BaseServiceDefinitionCollectionA collection of services that are only registered if a condition is met. This is useful for conditional service registration, for example based on a configuration value.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- condition: str | bool | LazySettingReference | Sequence[str | bool | LazySettingReference] | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ServiceDefinition[source]¶
Bases:
BaseModelDescribes a service that our container is able to register. Services within a collection can override each other, if explicitely stated. This is useful for conditional service change (for example, based on a configuration value).
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- base: str | LazySettingReference | LazyServiceReference | Sequence[str | LazySettingReference | LazyServiceReference] | None¶
base type for service, aka the interface we are implementing, if different from type
- constructor: str | LazySettingReference | LazyServiceReference | Sequence[str | LazySettingReference | LazyServiceReference] | None¶
constructor name, if not default one
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: str | LazySettingReference | LazyServiceReference | Sequence[str | LazySettingReference | LazyServiceReference] | None¶
service type, aka the implementation we are using, if different from base
- class ServiceDefinitionCollection[source]¶
Bases:
BaseServiceDefinitionCollectionFinal class for a service collection. Iterate on it to get a flattened (one level) and merged (services with same name that allows overrides are merged together) list of services.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].