Module directory_server.config

Configuration management using pydantic-settings.

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"
    host: str = "127.0.0.1"
    port: int = 5222

    max_peers: int = 10000
    max_message_size: int = 2097152  # 2MB
    max_line_length: int = 65536  # 64KB - maximum JSON-line message length
    max_json_nesting_depth: int = 10  # Maximum nesting depth for JSON parsing
    message_rate_limit: int = 10  # messages per second (sustained, lowered from 100)
    message_burst_limit: int = 100  # maximum burst size (generous, allows 10s at max rate)
    # 0 = never disconnect (slowdown only), >0 = disconnect after N violations
    rate_limit_disconnect_threshold: int = 0

    # Batch size for concurrent broadcasts to limit memory usage
    # Lower values = less memory, higher values = faster broadcasts
    broadcast_batch_size: int = 50

    log_level: str = "INFO"

    motd: str = "JoinMarket Directory Server https://github.com/m0wer/joinmarket-ng"

    health_check_host: str = "127.0.0.1"
    health_check_port: int = 8080

Base 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 from model_config['env_file'] should be used. You can also pass None to indicate that environment variables should not be loaded from an env file.
_env_file_encoding
The env file encoding, e.g. 'latin-1'. Defaults to None.
_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 None type(None). Defaults to None type(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 None if _cli_parse_args is None. 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 None type(None). Defaults to _env_parse_none_str value if set. Otherwise, defaults to "null" if _cli_avoid_json is False, and "None" if _cli_avoid_json is True.
_cli_hide_none_type
Hide None values in CLI help text. Defaults to False.
_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 bool fields should be implicitly converted into CLI boolean flags. (e.g. –flag, –no-flag). Defaults to False.
_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.

self is explicitly positional-only to allow self as a field name.

Ancestors

  • pydantic_settings.main.BaseSettings
  • pydantic.main.BaseModel

Class variables

var broadcast_batch_size : int

The type of the None singleton.

var health_check_host : str

The type of the None singleton.

var health_check_port : int

The type of the None singleton.

var host : str

The type of the None singleton.

var log_level : str

The type of the None singleton.

var max_json_nesting_depth : int

The type of the None singleton.

var max_line_length : int

The type of the None singleton.

var max_message_size : int

The type of the None singleton.

var max_peers : int

The type of the None singleton.

var message_burst_limit : int

The type of the None singleton.

var message_rate_limit : int

The type of the None singleton.

var model_config : ClassVar[pydantic_settings.main.SettingsConfigDict]

The type of the None singleton.

var motd : str

The type of the None singleton.

var network : Literal['mainnet', 'testnet', 'signet', 'regtest']

The type of the None singleton.

var port : int

The type of the None singleton.

var rate_limit_disconnect_threshold : int

The type of the None singleton.