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.

Modules§

platform
The variables running-process-platform-internal declares and reads, including the ones this crate reads too. See all_declared for the combined inventory. Every environment variable this crate reads in production, declared in one place (#1101).

Macros§

declare_env_vars
Declare a crate’s own variables with the shared mechanism; see running_process_platform_internal::declare_env_vars. Re-exported so a crate built on running-process can keep its own table without depending on the platform layer directly. Declare environment variables as EnvVar constants plus a table of all of them, so a crate’s inventory is one list rather than scattered literals.

Structs§

EnvVar
One environment variable the reader 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_IDENTITY_STAMP
Dev-scope daemon identity stamp, <version>-<16 hex of the executable's blake3>; ignored outside dev scope.
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
Declared by the platform layer, which reads it too: [running_process_platform_internal :: env_vars :: KILL_DRAIN_TIMEOUT_MS].
LOCALAPPDATA
Declared by the platform layer, which reads it too: [running_process_platform_internal :: env_vars :: LOCALAPPDATA].
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
Declared by the platform layer, which reads it too: [running_process_platform_internal :: env_vars :: PATH].
SERVICE_DEF_DIR
Where service definitions are read from.
TMPDIR
Declared by the platform layer, which reads it too: [running_process_platform_internal :: env_vars :: TMPDIR].
USERNAME
Windows account name, mixed into the daemon pipe name.
XDG_CONFIG_HOME
Declared by the platform layer, which reads it too: [running_process_platform_internal :: env_vars :: XDG_CONFIG_HOME].
XDG_DATA_HOME
Declared by the platform layer, which reads it too: [running_process_platform_internal :: env_vars :: XDG_DATA_HOME].
XDG_RUNTIME_DIR
Declared by the platform layer, which reads it too: [running_process_platform_internal :: env_vars :: XDG_RUNTIME_DIR].

Functions§

all_declared
Every environment variable read by this crate or by the platform layer it builds on, once each, sorted by name.
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 the reader owns: on only for a recognised affirmative.
os_named
Read a variable whose name is caller-supplied data, exactly as the host wrote it.
string_named
os_named as Unicode: None when unset or not valid Unicode, matching std::env::var.
value_is_affirmative_foreign
Whether a value already in hand reads as a foreign switch being on.