Skip to main content

LifecycleConfig

Struct LifecycleConfig 

Source
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: usize

The 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: Duration

The 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: Duration

The 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: Duration

How 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: usize

The largest request body accepted (defends memory; passed through to the wire parser’s cap).

§max_response_body: usize

The 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: bool

Whether 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

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> LifecycleConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LifecycleConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LifecycleConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,