services¶
Service ¶
Bases: ABC
Abstract base class for all services in the application. This may be needed in the future to ensure a common interface
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
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|