Module orderbook_watcher.config
Configuration management for orderbook watcher.
Functions
def get_settings() ‑> Settings-
Expand source code
def get_settings() -> Settings: return Settings()
Classes
class Settings (**values: Any)-
Expand source code
class Settings(BaseSettings): model_config = SettingsConfigDict( env_file=".env", env_file_encoding="utf-8", case_sensitive=False ) network: Literal["mainnet", "testnet", "signet", "regtest"] = "mainnet" directory_nodes: str = "" tor_socks_host: str = "127.0.0.1" tor_socks_port: int = 9050 mempool_api_url: str = ( "http://mempopwcaqoi7z5xj5zplfdwk5bgzyl3hemx725d4a3agado6xtk3kqd.onion/api" ) mempool_web_url: str | None = "https://mempool.sgn.space" mempool_web_onion_url: str | None = ( "http://mempopwcaqoi7z5xj5zplfdwk5bgzyl3hemx725d4a3agado6xtk3kqd.onion" ) http_host: str = "0.0.0.0" http_port: int = 8000 update_interval: int = 60 log_level: str = "INFO" max_message_size: int = 2097152 # 2MB connection_timeout: float = 30.0 uptime_grace_period: int = 60 # seconds - grace period before tracking uptime def get_directory_nodes(self) -> list[tuple[str, int]]: if not self.directory_nodes: return [] nodes = [] for node in self.directory_nodes.split(","): node = node.strip() if not node: continue if ":" in node: host, port_str = node.rsplit(":", 1) nodes.append((host, int(port_str))) else: nodes.append((node, 5222)) return nodesBase class for settings, allowing values to be overridden by environment variables.
This is useful in production for secrets you do not wish to save in code, it plays nicely with docker(-compose), Heroku and any 12 factor app design.
All the below attributes can be set via
model_config.Args
_case_sensitive- Whether environment and CLI variable names should be read with case-sensitivity.
Defaults to
None. _nested_model_default_partial_update- Whether to allow partial updates on nested model default object fields.
Defaults to
False. _env_prefix- Prefix for all environment variables. Defaults to
None. _env_file- The env file(s) to load settings values from. Defaults to
Path(''), which means that the value frommodel_config['env_file']should be used. You can also passNoneto indicate that environment variables should not be loaded from an env file. _env_file_encoding- The env file encoding, e.g.
'latin-1'. Defaults toNone. _env_ignore_empty- Ignore environment variables where the value is an empty string. Default to
False. _env_nested_delimiter- The nested env values delimiter. Defaults to
None. _env_nested_max_split- The nested env values maximum nesting. Defaults to
None, which means no limit. _env_parse_none_str- The env string value that should be parsed (e.g. "null", "void", "None", etc.)
into
Nonetype(None). Defaults toNonetype(None), which means no parsing should occur. _env_parse_enums- Parse enum field names to values. Defaults to
None., which means no parsing should occur. _cli_prog_name- The CLI program name to display in help text. Defaults to
Noneif _cli_parse_args isNone. Otherwise, defaults to sys.argv[0]. _cli_parse_args- The list of CLI arguments to parse. Defaults to None.
If set to
True, defaults to sys.argv[1:]. _cli_settings_source- Override the default CLI settings source with a user defined instance. Defaults to None.
_cli_parse_none_str- The CLI string value that should be parsed (e.g. "null", "void", "None", etc.) into
Nonetype(None). Defaults to _env_parse_none_str value if set. Otherwise, defaults to "null" if _cli_avoid_json isFalse, and "None" if _cli_avoid_json isTrue. _cli_hide_none_type- Hide
Nonevalues in CLI help text. Defaults toFalse. _cli_avoid_json- Avoid complex JSON objects in CLI help text. Defaults to
False. _cli_enforce_required- Enforce required fields at the CLI. Defaults to
False. _cli_use_class_docs_for_groups- Use class docstrings in CLI group help text instead of field descriptions.
Defaults to
False. _cli_exit_on_error- Determines whether or not the internal parser exits with error info when an error occurs.
Defaults to
True. _cli_prefix- The root parser command line arguments prefix. Defaults to "".
_cli_flag_prefix_char- The flag prefix character to use for CLI optional arguments. Defaults to '-'.
_cli_implicit_flags- Whether
boolfields should be implicitly converted into CLI boolean flags. (e.g. –flag, –no-flag). Defaults toFalse. _cli_ignore_unknown_args- Whether to ignore unknown CLI args and parse only known ones. Defaults to
False. _cli_kebab_case- CLI args use kebab case. Defaults to
False. _cli_shortcuts- Mapping of target field name to alias names. Defaults to
None. _secrets_dir- The secret files directory or a sequence of directories. Defaults to
None.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.Ancestors
- pydantic_settings.main.BaseSettings
- pydantic.main.BaseModel
Class variables
var connection_timeout : float-
The type of the None singleton.
var directory_nodes : str-
The type of the None singleton.
var http_host : str-
The type of the None singleton.
var http_port : int-
The type of the None singleton.
var log_level : str-
The type of the None singleton.
var max_message_size : int-
The type of the None singleton.
var mempool_api_url : str-
The type of the None singleton.
var mempool_web_onion_url : str | None-
The type of the None singleton.
var mempool_web_url : str | None-
The type of the None singleton.
var model_config : ClassVar[pydantic_settings.main.SettingsConfigDict]-
The type of the None singleton.
var network : Literal['mainnet', 'testnet', 'signet', 'regtest']-
The type of the None singleton.
var tor_socks_host : str-
The type of the None singleton.
var tor_socks_port : int-
The type of the None singleton.
var update_interval : int-
The type of the None singleton.
var uptime_grace_period : int-
The type of the None singleton.
Methods
def get_directory_nodes(self) ‑> list[tuple[str, int]]-
Expand source code
def get_directory_nodes(self) -> list[tuple[str, int]]: if not self.directory_nodes: return [] nodes = [] for node in self.directory_nodes.split(","): node = node.strip() if not node: continue if ":" in node: host, port_str = node.rsplit(":", 1) nodes.append((host, int(port_str))) else: nodes.append((node, 5222)) return nodes