Configuration¶
Python API reference for the tolomeo.config package.
load_config reads and validates the TOML configuration file into a Config; get_config returns the one loaded for the
running process. For the file format and every key, see the Configuration Reference.
Loading¶
tolomeo.config.load_config(path=None)
¶
Load a configuration, without touching the process-level cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path | None
|
An explicit file to read. Outranks every other source. When
omitted the precedence order applies: |
None
|
Returns:
| Type | Description |
|---|---|
Config
|
The loaded configuration, or the built-in defaults when no file exists. |
Raises:
| Type | Description |
|---|---|
ConfigError
|
The file is unreadable or malformed, or its contents fail validation. Validation failures report every offending key at once. |
Source code in tolomeo/config/loader.py
tolomeo.config.search_paths()
¶
Return the configuration search paths, highest precedence first.
Resolved on each call rather than at import, so the working directory and home directory are read when the configuration is actually loaded.
Returns:
| Type | Description |
|---|---|
list[Path]
|
Candidate configuration file paths in precedence order. |
Source code in tolomeo/config/loader.py
tolomeo.config.get_config()
cached
¶
Return the service configuration, loading it on first use.
One process runs one service with one configuration, so the file is read
once and every component reads the same values thereafter. Point a service
at its own file with the TOLOMEO_CONFIG environment variable.
Returns:
| Type | Description |
|---|---|
Config
|
The service configuration, or the built-in defaults when no file exists. |
Raises:
| Type | Description |
|---|---|
ConfigError
|
A configuration file was found but cannot be used. |
Source code in tolomeo/config/process.py
tolomeo.config.reset_config()
¶
Clear the cached configuration, so the next read reloads it.
Intended for tests; the suite resets between tests so that a configuration cannot leak from one test into another.
Models¶
tolomeo.config.Config
¶
Bases: BaseModel
A fully loaded configuration.
extra="forbid" rejects unknown top-level sections, and applies inside
nats and service too. It deliberately does not reach inside a
plugin's table: a plugin validates its own table against the model it
declares as Meta.config_model.
hide_input_in_errors=True drops the offending value from a validation
error's rendering. This is the model whose validation pass constructs the
ValidationError that load_config turns into a ConfigError, so it
is the model this must be set on: the same setting on a nested model such as
NATSConfig has no effect on the error that actually gets raised. Without
it, a failed cross-field check such as
_reject_multiple_authentication_styles would echo the raw, still-unwrapped
[nats] table — including a plaintext password or token — into the message
that ends up in a startup log.
Attributes:
| Name | Type | Description |
|---|---|---|
nats |
NATSConfig
|
Broker connection settings. |
service |
ServiceConfig
|
Service-level settings. |
plugins |
Dict[str, Dict[str, Any]]
|
Per-plugin configuration tables, keyed by plugin id. A plugin
normally reads through |
Source code in tolomeo/config/models.py
plugin_config(plugin_id)
¶
Return the configuration table declared for a plugin.
The result is a copy, so a caller that mutates it cannot reconfigure later readers in the process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_id
|
str
|
The plugin's own id, as assigned during |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
The plugin's configuration table, or an empty mapping when no table |
Dict[str, Any]
|
is declared for that id. |
Source code in tolomeo/config/models.py
tolomeo.config.NATSConfig
¶
Bases: BaseModel
Broker connection settings.
Every attribute except url and reconnect_time_wait_s defaults to
None meaning unset. An unset attribute is omitted from the connect call
rather than passed as a value the framework guessed at, so the client
library's own default applies.
Numeric attributes are strict: a boolean is rejected rather than coerced to an integer, which pydantic's default mode would otherwise do.
Attributes:
| Name | Type | Description |
|---|---|---|
url |
str
|
Broker to connect to. |
user |
str | None
|
Username for user/password authentication. |
password |
SecretStr | None
|
Password for user/password authentication. Wrapped so it
cannot leak through |
token |
SecretStr | None
|
Token for token authentication. Wrapped so it cannot leak
through |
credentials_file |
str | None
|
Path to an nkey/JWT credentials file. |
tls_ca_file |
str | None
|
Path to a CA bundle, verified readable at load time. |
tls_hostname |
str | None
|
Hostname the broker's certificate is expected to present. |
reconnect_time_wait_s |
StrictInt | StrictFloat
|
Seconds to wait between reconnection attempts. |
max_reconnect_attempts |
StrictInt | None
|
Retry ceiling. Unset means the client library's own default, which is 60 attempts rather than unlimited. |
Source code in tolomeo/config/models.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
tls_context
cached
property
¶
SSL context built from tls_ca_file, or None when TLS is unset.
The client library takes a prepared context rather than a CA path. Built on first access and cached; the file was already verified readable at load time, so this cannot fail for a configuration that loaded.
tolomeo.config.ServiceConfig
¶
Bases: BaseModel
Service-level settings.
Attributes:
| Name | Type | Description |
|---|---|---|
heartbeat_interval_ms |
StrictInt
|
Heartbeat cadence in milliseconds. |
Source code in tolomeo/config/models.py
Errors¶
tolomeo.config.ConfigError
¶
Bases: Exception
Raised when a configuration cannot be used.
Always raised at load time, never mid-run, and names the offending file. Validation failures carry pydantic's report, which names every offending key at once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Description of what is wrong. |
required |
path
|
str | Path | None
|
Configuration file the problem was found in, if any. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
path |
The offending file as a string, or |