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.

classmethod build_from_yaml(loader, node)[source]

Secondary constructor implementing the pyyaml constructor interface.

Return type:

Self

__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

model_config: ClassVar[ConfigDict] = {}

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

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_config: ClassVar[ConfigDict] = {}

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

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.

classmethod build_from_yaml(loader, node)[source]

Secondary constructor implementing the pyyaml constructor interface.

Return type:

Self

__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.

resolve(settings)[source]
default: Any
model_config: ClassVar[ConfigDict] = {}

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

target: str