Expand description
parse TOML config and generate requests from it
§Sōzu’s configuration
This module is responsible for parsing the config.toml
provided by the flag --config
when starting Sōzu.
Here is the workflow for generating a working config:
config.toml -> FileConfig -> ConfigBuilder -> Config
config.toml
is parsed to FileConfig
, a structure that itself contains a lot of substructures
whose names start with File-
and end with -Config
, like FileHttpFrontendConfig
for instance.
The instance of FileConfig
is then passed to a ConfigBuilder
that populates a final Config
with listeners and clusters.
To illustrate:
use sozu_command_lib::config::{FileConfig, ConfigBuilder};
let file_config = FileConfig::load_from_path("../config.toml")
.expect("Could not load config.toml");
let config = ConfigBuilder::new(file_config, "../assets/config.toml")
.into_config()
.expect("Could not build config");
Note that the path to config.toml
is used twice: the first time, to parse the file,
the second time, to keep the path in the config for later use.
However, there is a simpler way that combines all this:
use sozu_command_lib::config::Config;
let config = Config::load_from_path("../assets/config.toml")
.expect("Could not build config from the path");
§How values are chosen
Values are chosen in this order of priority:
- values defined in a section of the TOML file, for instance, timeouts for a specific listener
- values defined globally in the TOML file, like timeouts or buffer size
- if a variable has not been set in the TOML file, it will be set to a default defined here
Structs§
- Backend
Config - Config
- Sōzu configuration, populated with clusters and listeners.
- Config
Builder - A builder that converts FileConfig to Config
- File
Cluster Config - File
Cluster Frontend Config - File
Config - Parsed from the TOML config provided by the user.
- Http
Cluster Config - Http
Frontend Config - Listener
Builder - An HTTP, HTTPS or TCP listener as parsed from the
Listeners
section in the toml - Metrics
Config - TcpCluster
Config - TcpFrontend
Config
Enums§
- Cluster
Config - Config
Error - File
Cluster Protocol Config - Incompatibility
Kind - Listener
Protocol - Missing
Kind - Path
Rule Type
Constants§
- DEFAULT_
ACCEPT_ QUEUE_ TIMEOUT - timeout to accept connection events in the accept queue (60 seconds)
- DEFAULT_
AUTOMATIC_ STATE_ SAVE - wether to save the state automatically (false)
- DEFAULT_
BACK_ TIMEOUT - maximum time of inactivity for a backend socket (30 seconds)
- DEFAULT_
BUFFER_ SIZE - size of the buffers, in bytes (16 KB)
- DEFAULT_
CIPHER_ SUITES - DEFAULT_
COMMAND_ BUFFER_ SIZE - size of the buffer for the channels, in bytes. Must be bigger than the size of the data received. (1 MB)
- DEFAULT_
CONNECT_ TIMEOUT - maximum time to connect to a backend server (3 seconds)
- DEFAULT_
DISABLE_ CLUSTER_ METRICS - wether to avoid register cluster metrics in the local drain
- DEFAULT_
FRONT_ TIMEOUT - maximum time of inactivity for a frontend socket (60 seconds)
- DEFAULT_
GROUPS_ LIST - DEFAULT_
LOG_ TARGET - for both logs and access logs
- DEFAULT_
MAX_ BUFFERS - maximum number of buffers (1 000)
- DEFAULT_
MAX_ COMMAND_ BUFFER_ SIZE - maximum size of the buffer for the channels, in bytes. (2 MB)
- DEFAULT_
MAX_ CONNECTIONS - maximum number of simultaneous connections (10 000)
- DEFAULT_
MIN_ BUFFERS - minimum number of buffers (1)
- DEFAULT_
REQUEST_ TIMEOUT - maximum time to receive a request since the connection started (10 seconds)
- DEFAULT_
RUSTLS_ CIPHER_ LIST - provides all supported cipher suites exported by Rustls TLS provider as it support only strongly secure ones.
- DEFAULT_
SEND_ TLS_ 13_ TICKETS - Number of TLS 1.3 tickets to send to a client when establishing a connection. The tickets allow the client to resume a session. This protects the client agains session tracking. Increases the number of getrandom syscalls, with little influence on performance. Defaults to 4.
- DEFAULT_
SIGNATURE_ ALGORITHMS - DEFAULT_
STICKY_ NAME - a name applied to sticky sessions (“SOZUBALANCEID”)
- DEFAULT_
WORKER_ AUTOMATIC_ RESTART - wether a worker is automatically restarted when it crashes (true)
- DEFAULT_
WORKER_ COUNT - number of workers, i.e. Sōzu processes that scale horizontally (2)
- DEFAULT_
WORKER_ TIMEOUT - maximum time to wait for a worker to respond, until it is deemed NotAnswering (10 seconds)
- DEFAULT_
ZOMBIE_ CHECK_ INTERVAL - Interval between checking for zombie sessions, (30 minutes)
- MAX_
LOOP_ ITERATIONS