harp.services.references

Inheritance diagram of harp.services.references

class BaseReference[source]

Bases: BaseModel

Base class for references. Mostly there to add some interface documentation.

Create a new model by parsing and validating input data from keyword arguments.

Raises pydantic_core.ValidationError if the input data cannot be validated.

__init__(**data)[source]

Create a new model by parsing and validating input data from keyword arguments.

Raises pydantic_core.ValidationError if the input data cannot be validated.

Parameters:

data (Any)

Return type:

None

classmethod build_from_yaml(loader, node)[source]

Secondary constructor implementing the pyyaml constructor interface.

Return type:

Self

model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

class LazyServiceReference[source]

Bases: BaseReference

Reference to a service, that will be resolved the latest possible, when the instance will actually be needed.

Create a new model by parsing and validating input data from keyword arguments.

Raises pydantic_core.ValidationError if the input data cannot be validated.

classmethod build_from_yaml(loader, node)[source]

Secondary constructor implementing the pyyaml constructor interface.

Return type:

Self

resolve(resolver, context)[source]

Resolve reference value in using the given resolver (callable) and resolution context.

model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'target': FieldInfo(annotation=Union[str, list[str]], required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

target: str | list[str]

Reference target, a.k.a. the service symbolic name. Can be either a string, or a list of strings. The later will resolve as the first available service in the list.

class LazySettingReference[source]

Bases: BaseReference

Reference to a setting value, that will be resolved when the settings are bound to the service definitions collection, when calling harp.services.Container.load().

Use this in services.yml files using the !cfg constructor:

foo: !cfg "foo"

Can be provided a two-element list for defaults:

foo: !cfg ["foo", "default if no «foo» in bound settings"]

Create a new model by parsing and validating input data from keyword arguments.

Raises pydantic_core.ValidationError if the input data cannot be validated.

__init__(target=None, **kwargs)[source]

Create a new model by parsing and validating input data from keyword arguments.

Raises pydantic_core.ValidationError if the input data cannot be validated.

classmethod build_from_yaml(loader, node)[source]

Secondary constructor implementing the pyyaml constructor interface.

Return type:

Self

resolve(settings)[source]
default: Any
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'default': FieldInfo(annotation=Any, required=False, default=<not set>), 'target': FieldInfo(annotation=str, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

target: str