Skip to main content

Module env_vars

Module env_vars 

Source
Expand description

Every environment variable this crate reads, declared in one place.

An environment variable is an interface. Other repositories embed this crate – soldr vendors it – and have to reason about what it reads, which until now meant grepping every call site. DECLARED is that list, and declaration_table_covers_every_variable keeps it honest: a new RUNNING_PROCESS_* literal anywhere in the crate fails the build unless it is declared here.

§Why booleans get two accessors rather than one

“Is this switch on?” has two defensible answers when the value is neither clearly on nor clearly off, and which one is right depends on who owns the variable – not on the call site, which is how a codebase ends up with five parsers that disagree.

  • flag_owned is for switches this crate defines. Unknown means off. The value space is ours, so anything outside it is a typo, and a typo in SOMETHING_DISABLE must not disable something.
  • flag_foreign is for values written by someone else, where absence of a recognised falsy spelling is better read as “set”. Unknown means on. The daemon marker is this kind: a process that says it is a daemon in a spelling we did not anticipate is still a daemon, and a stray =0 must never exempt it from reaping.
  • flag_opt_out is for an escape hatch that is on until someone turns it off. Unset means on, which is the whole difference from the other two.

Both trim and lowercase before comparing, so " True " and "TRUE" agree.

§The table and the parser must agree

Writing the table turned up a switch whose declared default and whose parser disagreed – BROKER_OWNED_BIND is documented as on by default but was first declared with semantics that read unset as off. That is the class of bug this module exists to end, so an_unset_flag_matches_its_declared_default now checks the two against each other for every declared flag.

Structs§

EnvVar
One environment variable this crate reads.

Enums§

EnvKind
What kind of value a variable carries, and how it is read.
Owner
Who decides what values a variable may take.

Constants§

BROKER_ALLOW_PRIVILEGED
Opt out of the broker’s refusal to start as root or LocalSystem.
BROKER_CLIENT_TIMEOUT_MS
Broker client request timeout, in milliseconds.
BROKER_CRASH_DUMP_DIR
Where broker crash dumps are written.
BROKER_HELLO_PERF_GUARD
Run the broker Hello latency guard.
BROKER_HELLO_TIMEOUT_MS
Broker Hello handshake timeout, in milliseconds.
BROKER_HTTP_BIND
Bind address for the broker HTTP aggregator.
BROKER_HTTP_PORT
Port for the broker HTTP aggregator.
BROKER_LISTENER_FD
Descriptor of a listening socket the broker already bound and passed.
BROKER_MAX_INFLIGHT_HANDLERS
Maximum broker request handlers running at once.
BROKER_OWNED_BIND
Escape hatch: set falsy to fall back to spawn-then-probe.
BROKER_V1_BACKEND_NAMESPACE
Backend namespace handed to a v1 broker backend.
BROKER_V1_BACKEND_PIPE
Endpoint a v1 broker backend should serve on.
BROKER_V1_INSTANCE
Instance identifier for a v1 broker backend.
BROKER_V1_SERVICE_NAME
Service name a v1 broker backend registers under.
BROKER_V1_SERVICE_VERSION
Service version a v1 broker backend reports.
BROKER_V1_SESSION_TOKEN
Session token a v1 broker backend presents to the broker.
BROKER_V1_SOCKET
Broker endpoint a v1 backend dials.
BROKER_V1_TRACEPARENT
W3C traceparent propagated into a v1 broker backend.
BROKER_V1_TRACESTATE
W3C tracestate propagated into a v1 broker backend.
CHILD_PID_LOG_PATH
Append each spawned child PID to this file (test harness seam).
CLIENT_CONNECT_TIMEOUT_MS
Daemon client connect timeout, in milliseconds.
CLIENT_RPC_TIMEOUT_MS
Daemon client RPC timeout, in milliseconds.
DAEMON_SCOPE
Daemon scope selector; dev gives a CWD-scoped daemon for tests.
DAEMON_SHADOWED
Marks a daemon already running from its shadow copy.
DAEMON_START_TIMEOUT_MS
How long a client waits for a freshly spawned daemon to bind its socket, in milliseconds.
DECLARED
Every environment variable this crate reads.
DISABLE
Canonical escape hatch: bypass the broker entirely.
FAKE_BACKEND
TEST-ONLY: dial this endpoint directly, skipping broker negotiation.
GITHUB_ACTIONS
Set by GitHub Actions; tests wait longer for a shared runner.
INVOCATION_ID
Set by systemd for a unit invocation; identifies the launching unit.
IS_DAEMON
Marks a process spawned as a daemon, for originator reaping.
KILL_DRAIN_TIMEOUT_MS
How long kill() waits for output capture to drain, in milliseconds.
LOCALAPPDATA
Windows per-user application data root.
MANIFEST_DIR
Where broker cache manifests are read and written.
NO_TRACKING
Disable daemon IPC and process tracking.
ORIGINATOR
Identifies the process that originated a spawn tree.
PATH
Executable search path, forwarded to the symbolization worker.
SERVICE_DEF_DIR
Where service definitions are read from.
TMPDIR
macOS per-session temporary directory; a broker endpoint root.
USERNAME
Windows account name, mixed into the daemon pipe name.
XDG_CONFIG_HOME
XDG per-user configuration root; where service definitions are read.
XDG_DATA_HOME
XDG per-user data root, used by the daemon runtime collector.
XDG_RUNTIME_DIR
XDG per-user runtime root; where broker sockets are placed.

Functions§

flag_foreign
Read a switch someone else writes: off only for a recognised negative.
flag_opt_out
Read an escape hatch that is on unless turned off.
flag_owned
Read a switch this crate owns: on only for a recognised affirmative.
value_is_affirmative_foreign
Whether a value already in hand reads as a foreign switch being on.