services¶
Service ¶
Service(*args, **kwargs)
Bases: ABC
A base class for all services.
This abstract base class defines the interface that all services should inherit from. It serves as a marker interface to identify service implementations across the system.
Initializes the service.
Source code in src/clabe/services.py
28 29 30 |
|
build_runner ¶
Builds a runner function for the service.
Subclasses must implement this method to return a callable that can be executed by the launcher.
Source code in src/clabe/services.py
32 33 34 35 36 37 38 |
|
ServiceSettings ¶
Bases: BaseSettings
, ABC
Base class for service settings with YAML configuration support.
This class provides automatic YAML configuration loading using pydantic-settings. The configuration is loaded from files defined in KNOWN_CONFIG_FILES.
Attributes:
Name | Type | Description |
---|---|---|
__yml_section__ |
Optional[str]
|
Optional class variable to override the config section name |
Example
# Define a settings class
class MyServiceSettings(ServiceSettings):
__yml_section__: ClassVar[str] = "my_service"
host: str = "localhost"
port: int = 8080
enabled: bool = True
# Usage will automatically load from YAML files
settings = MyServiceSettings()
settings_customise_sources
classmethod
¶
settings_customise_sources(
settings_cls: Type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
env_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
) -> Tuple[PydanticBaseSettingsSource, ...]
Customizes the settings sources to include the safe YAML settings source.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
settings_cls
|
Type[BaseSettings]
|
The settings class. |
required |
init_settings
|
PydanticBaseSettingsSource
|
The initial settings source. |
required |
env_settings
|
PydanticBaseSettingsSource
|
The environment settings source. |
required |
dotenv_settings
|
PydanticBaseSettingsSource
|
The dotenv settings source. |
required |
file_secret_settings
|
PydanticBaseSettingsSource
|
The file secret settings source. |
required |
Returns:
Type | Description |
---|---|
Tuple[PydanticBaseSettingsSource, ...]
|
A tuple of settings sources. |
Source code in src/clabe/services.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|