pub struct LifecycleConfig {
pub max_inflight: usize,
pub request_timeout: Duration,
pub read_deadline: Duration,
pub drain_timeout: Duration,
pub max_body: usize,
pub max_response_body: usize,
pub stamp_correlation_id: bool,
pub ready_path: Option<String>,
pub health_path: Option<String>,
}Expand description
Tunables for the server lifecycle. Every field is public so an embedder can
dial them; Default is the deployed shape.
Fields§
§max_inflight: usizeThe most requests whose handlers may execute CONCURRENTLY. A request
arriving while the slots are full is shed with 503 immediately
(bounded backpressure — never queued into an unbounded hang).
request_timeout: DurationThe wall-clock budget for a single handler call. A handler that runs
past it yields 503 and frees the slot, so a slow handler cannot wedge
a connection (or a slot) forever.
read_deadline: DurationThe wall-clock budget for READING one request off a connection (the slow-header / slow-body deadline). A client that connects and then stalls — sending a partial head or dribbling a body — is dropped when this elapses rather than held forever (the slowloris defense: a stalled peer can never pin a connection or a slot).
drain_timeout: DurationHow long a graceful Lifecycle::drain waits for in-flight requests to
finish before returning and reporting the still-running count as
force-closed.
max_body: usizeThe largest request body accepted (defends memory; passed through to the wire parser’s cap).
max_response_body: usizeThe largest RESPONSE body the server will ship. A handler that produces a
body past this cap is refused with a defined 500 (the giant body is
never serialized onto the wire), defending server and peer memory against
a handler that computes an unbounded response.
stamp_correlation_id: boolWhether every response carries an X-Correlation-Id (echoing the
client’s, else a server-assigned one). ON for the lifecycle-aware
super::server::spawn_with_lifecycle entry; OFF for the plain
super::server::serve/super::server::spawn entries so the
cross-tier byte-for-byte differential is unperturbed (two independent
processes would assign different ids — that is the ONE thing a
byte-identical differential cannot tolerate).
ready_path: Option<String>The path that answers a READINESS probe, when one is configured.
None — the default — reserves nothing, so a handler owns every path it
declares and the cross-tier byte-for-byte differential is unperturbed. Name
a path (LOGOS_READY_PATH=/readyz) and the server answers it BEFORE
admission: 200 while ready, 503 once draining or not yet ready. Opting
in is what makes a deployment’s probe work; not opting in is what keeps the
language from quietly owning two of your routes.
health_path: Option<String>The path that answers a LIVENESS probe, when one is configured. 200 for as
long as the process is answering at all — deliberately NOT gated on
readiness, because a draining server is alive and must not be killed for
shedding. None by default, for the same reason as Self::ready_path.
Implementations§
Source§impl LifecycleConfig
impl LifecycleConfig
Sourcepub fn serve_default() -> Self
pub fn serve_default() -> Self
The config the plain super::server::serve/super::server::spawn
entries use: the full lifecycle (readiness, backpressure, per-request
timeout, drain) EXCEPT the correlation-id header, which is gated off so
the cross-tier byte-for-byte differential stays byte-identical.
The plain entries start READY (no orchestrator flips readiness), and use
the historical connection bound super::server::MAX_INFLIGHT so their
behavior is unchanged from before the lifecycle existed.
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Self::serve_default with any knob the environment names layered over it.
This is the seam that gives EVERY tier the same lifecycle without any tier
knowing about it. The compiled Serve statement lowers to a call that routes
through the plain server entry, so sourcing the config here means a deployed
binary honors these names with no change to code generation at all — exactly
the trick the port override already plays. The interpreted and bytecode
servers read the same function, so the three tiers cannot drift.
Every name is optional and an unparseable value is ignored rather than fatal: a typo in a deployment’s environment must not stop a server booting.
Sourcepub fn from_env_with(get: impl Fn(&str) -> Option<String>) -> Self
pub fn from_env_with(get: impl Fn(&str) -> Option<String>) -> Self
Self::from_env against an arbitrary lookup — the pure law, so it can be
tested without touching the process environment.
Trait Implementations§
Source§impl Clone for LifecycleConfig
impl Clone for LifecycleConfig
Source§fn clone(&self) -> LifecycleConfig
fn clone(&self) -> LifecycleConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more