pub struct ServerState {
pub sites: HashMap<String, SiteBackend>,
pub console_inactivity_timeout: Duration,
pub audit: AuditLog,
pub auth_rate_limit_per_minute: Option<u32>,
pub request_timeout: Duration,
pub shutdown_grace_period: Duration,
pub migrate_backup_root: Option<PathBuf>,
}Expand description
Shared state for all HTTP handlers.
Holds one SiteBackend per configured site so a single server
can serve multiple clusters. Each request supplies the target site
via the X-Manta-Site header; handlers call
ServerState::infra_context (or, via the
handlers::RequestCtx extractor, the cached
RequestCtx::infra() shortcut) to retrieve the per-site data.
Plumbed through Axum’s State<Arc<ServerState>> extractor. Owned
by start_server and cloned (cheaply, since it’s an Arc) into
every spawned task.
Fields§
§sites: HashMap<String, SiteBackend>Per-site connection data, keyed by site name.
console_inactivity_timeout: DurationHow long a WebSocket console session may be idle before the server closes it. Protects against leaked Kubernetes pod attachments.
audit: AuditLogAudit trail every mutating request is recorded to (always the
log; Kafka too when [auditor.kafka] is configured).
auth_rate_limit_per_minute: Option<u32>Per-source-IP rate limit on /v2/auth/* (requests/minute).
None disables in-process rate limiting.
request_timeout: DurationGlobal request timeout applied to every HTTP route (router-level
TimeoutLayer). All long-running work (power transitions, SAT
dispatch) runs CLI-side, so this is the only request-timeout
knob the server has.
shutdown_grace_period: DurationDrain window for axum_server::Handle::graceful_shutdown on
SIGTERM / Ctrl+C. Sourced from
server.toml’s [server] shutdown_grace_period_secs.
migrate_backup_root: Option<PathBuf>Filesystem root that confines POST /migrate/{backup,restore}
file access. None disables both endpoints — even admin callers
must wait for an operator to opt in via [server] migrate_backup_root. The path is stored already-canonicalised
so per-request validation is a single starts_with against this.
Implementations§
Source§impl ServerState
impl ServerState
Sourcepub fn infra_context<'a>(
&'a self,
site_name: &'a str,
) -> Result<InfraContext<'a>, Error>
pub fn infra_context<'a>( &'a self, site_name: &'a str, ) -> Result<InfraContext<'a>, Error>
Build a borrowed InfraContext for the named site.
Called per-request so the service layer can work with its
existing &InfraContext<'_> API without taking ownership of the
underlying SiteBackend.
§Errors
Returns [Error::NotFound] when site_name is not in
Self::sites.
Auto Trait Implementations§
impl !RefUnwindSafe for ServerState
impl !UnwindSafe for ServerState
impl Freeze for ServerState
impl Send for ServerState
impl Sync for ServerState
impl Unpin for ServerState
impl UnsafeUnpin for ServerState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more