microserve.config module

Files

file config.cppm

Classes

struct microserve::ListenSpec
One listen entry on a server.
struct microserve::BackendConfig
Named upstream pool referenced by proxy_pass.
struct microserve::CacheConfig
Fixed cache pool for one server.
struct microserve::FederationPeer
Another federation node this process knows about.
struct microserve::FederationConfig
Optional overlay from federation.yaml.
struct microserve::AddressOption
Parsed --address: bind IP and/or server_name.
struct microserve::Config
Parsed CLI and YAML configuration (before resolve).
struct microserve::Config::TimeoutConfig
Connect/read/write timeouts for upstreams.
struct microserve::Config::ServerConfig
One virtual host as declared in YAML or built from CLI.
struct microserve::Config::ServerConfig::Location
One location: static root, auth, and/or proxy_pass.
struct microserve::ResolvedListen
One listen after dual-stack expansion.
struct microserve::ResolvedServer
One site after validation, expansion, and first-wins listen claims.
struct microserve::ResolvedConfig
Fully resolved configuration for the master process.

Enums

enum class Protocol { Http11, Http2c, Http2, Http3 }
Application protocol for a listen.
enum class CacheStrategy { Simple }
Lookup strategy for a fixed response-cache pool.
enum class FederationRole { Standalone, Member, Hub }
Role of this process in a federation.
enum class FederationMembership { None, Unverified, Certified }
How this node is enrolled in the federation.

Functions

auto try_parse_protocol(const std::string_view name) -> std::optional<Protocol>
Parse a protocol name (case-insensitive).
auto parse_protocol(const std::string_view name) -> Protocol
Parse a protocol name (case-insensitive).
auto try_parse_federation_role(const std::string_view name) -> std::optional<FederationRole>
Parse a federation role name, or std::nullopt if unknown.
auto parse_federation_role(const std::string_view name) -> FederationRole
Parse a federation role name.
auto try_parse_federation_membership(const std::string_view name) -> std::optional<FederationMembership>
Parse a federation membership name, or std::nullopt if unknown.
auto parse_federation_membership(const std::string_view name) -> FederationMembership
Parse a federation membership name.
auto federation_role_name(const FederationRole r) -> std::string_view constexpr
Canonical name of a federation role.
auto federation_membership_name(const FederationMembership m) -> std::string_view constexpr
Canonical name of a federation membership.
auto federation_node_urn(std::string_view node_id, const std::string_view urn_nid = "microserve") -> std::string
Membership SAN URI for a federation node certificate.
auto parse_protocol_list(const std::string_view csv) -> std::vector<Protocol>
Parse a comma-separated list of protocol names.
auto protocol_name(const Protocol p) -> std::string_view constexpr
Canonical name of a protocol (http11, http2c, http2, http3).
auto protocol_requires_tls(const Protocol p) -> bool constexpr
True if the protocol requires TLS (HTTP/2, HTTP/3).
auto protocol_is_cleartext(const Protocol p) -> bool constexpr
True if the protocol is cleartext (HTTP/1.1, h2c).
auto protocol_is_udp(const Protocol p) -> bool constexpr
True if the protocol is UDP-based (HTTP/3).
auto try_parse_cache_strategy(const std::string_view name) -> std::optional<CacheStrategy>
Parse a cache strategy name, or std::nullopt if unknown.
auto parse_cache_strategy(const std::string_view name) -> CacheStrategy
Parse a cache strategy name.
auto cache_strategy_name(const CacheStrategy s) -> std::string_view constexpr
Canonical name of a cache strategy.
auto parse_byte_size(const std::string_view raw) -> std::uint64_t
Parse a byte size (128, 128kb, 128mb, 1gb).
auto parse_address_option(const std::string_view s) -> AddressOption
Split --address into a bind IP and/or server_name.
auto parse_listen(const std::string& s) -> std::pair<std::string, unsigned short>
Parse a listen bind: bare port, host:port, or [ipv6]:port.
auto format_bind(const std::string_view host, const unsigned short port) -> std::string
Format a listen bind as a bare port, host:port, or [ipv6]:port.
auto make_cli_server(const Config& config) -> Config::ServerConfig
Build the single server implied by CLI listen flags.
auto is_valid_error_log_level(const std::string& error_log_level) -> bool
Checks if the provided error log level is valid.
auto count_verbosity_args(const int argc, char* argv[]) -> int
Counts the number of verbosity flags present in command-line arguments.
auto create_options_description() -> po::options_description
Command-line options for server configuration.
void print_help(const po::options_description& desc)
Prints the command-line options description along with usage examples.
auto parse_arguments(const int argc, char* argv[], Config& config, std::string& config_file) -> bool
Parses command line arguments into a structured options object.
auto parse_bind(const std::string& s) -> std::pair<std::string, unsigned short>
Split a host:port bind string on the last :.
auto resolve_bind_addr(const std::string& addr_str, const bool ipv6) -> std::pair<std::string, unsigned short>
Keep addr_str's port and force a wildcard address family.
auto bind_addrs(const std::string& addr_str, const bool ipv6_flag, const bool no_ipv4, const bool force_ipv4_only) -> std::vector<std::pair<std::string, unsigned short>>
Build the list of listen addresses for a bind string.
auto expand_listen(const std::string& bind, const bool ipv6_flag, const bool no_ipv4) -> std::vector<std::pair<std::string, unsigned short>>
Expand a listen bind into concrete (addr, port) sockets.
auto effective_protocols(const ListenSpec& listen, const Config::ServerConfig& server) -> const std::vector<Protocol>&
Protocols in effect for one listen entry.
auto proxy_pass_backend_name(const std::string_view proxy_pass, const std::vector<BackendConfig>& backends) -> std::optional<std::string>
Backend name referenced by a proxy_pass, if any.
auto resolve_config(const Config& config) -> ResolvedConfig
Resolve sites for the master process.
void apply_runtime_paths(Config& config)
Place relative logs under log_dir and a relative pid next to the executable.
auto load_config(const std::string& config_path) -> Config
Load and parse application configuration from the YAML file at config_path.
void load_federation(const std::string& path, Config& config)
Overlay federation.yaml onto an already-loaded Config.

Variables

int DEFAULT_PORT constexpr
std::string_view DEFAULT_ADDR constexpr
std::string_view DEFAULT_HOST constexpr
std::string_view DEFAULT_LOGLEVEL constexpr