1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Graceful shutdown, connection drain, and server hygiene for Chio HTTP
//! services.
//!
//! Every Chio process that binds an `axum::serve` listener shares the same three
//! obligations when the platform stops it (SIGTERM on a deploy, scale event, or
//! node rotation):
//!
//! 1. Notice the stop signal instead of dying on the runtime default action.
//! 2. Stop accepting, let in-flight requests finish, then exit, all inside a
//! bounded window so a stuck request cannot hold the process open forever.
//! 3. Refuse abusive load (oversized bodies, slow requests, connection floods)
//! with an explicit denial rather than unbounded resource growth.
//!
//! This crate centralizes those obligations so the serve sites converge on one
//! implementation instead of drifting apart:
//!
//! - [`ShutdownController`] installs a single signal handler and fans the result
//! out over a [`tokio::sync::watch`] channel that the serve loop and every
//! cooperating background task observe.
//! - [`apply_server_hygiene`] wraps a [`Router`](axum::Router) with a request
//! timeout, a global concurrency limit fronted by load shedding, and an
//! optional body-size cap.
//! - [`MaxConnListener`] caps the number of simultaneously accepted connections
//! with back-pressure at the accept loop.
//! - [`run_until_drained`] runs the serve future, bounds only the post-signal
//! drain (never the healthy uptime), and then runs a flush hook so a store
//! with a queued write is either made durable or surfaced as a loud error.
//!
//! The posture is fail-closed throughout. A signal handler that cannot be
//! installed logs and degrades to the platform default rather than crash-looping
//! at startup, and each hygiene limit denies (413 / 408 / 503) rather than
//! accepting work it cannot bound.
pub use ;
pub use ;
pub use ;
pub use ;