pub struct Config {Show 17 fields
pub port: u16,
pub cache_dir: String,
pub max_file_size_mb: usize,
pub request_timeout_secs: u64,
pub stream_idle_timeout_secs: u64,
pub worker_threads: usize,
pub initial_batch_size: usize,
pub max_batch_size: usize,
pub cache_max_age_days: u64,
pub cors_origins: Vec<String>,
pub max_concurrent_parses: usize,
pub mem_budget_mb: usize,
pub admission_queue_depth: usize,
pub admission_queue_timeout_secs: u64,
pub mem_shed_pct: u8,
pub metrics_enabled: bool,
pub api_token: Option<String>,
}Expand description
Server configuration.
Debug is implemented by hand (not derived) so the bearer token in
api_token is never leaked through logs, traces, or panic reports.
Fields§
§port: u16Port to listen on.
cache_dir: StringDirectory for cache storage.
max_file_size_mb: usizeMaximum file size in MB.
request_timeout_secs: u64Request timeout in seconds.
stream_idle_timeout_secs: u64Longest a socket write may make no progress before the connection is
closed (IFC_STREAM_IDLE_TIMEOUT_SECS, default 600; 0 disables).
This is enforced by the connection owner, so closing the transport
drops Hyper’s current frame, the response body, and its admission
reservation. Producer time does not count because no write is pending.
worker_threads: usizeNumber of worker threads for parallel processing.
initial_batch_size: usizeInitial batch size for fast first frame (first 3 batches).
max_batch_size: usizeMaximum batch size for throughput (batches 11+).
cache_max_age_days: u64Maximum cache age in days.
cors_origins: Vec<String>Allowed CORS origins (comma-separated, or “*” for all in development).
max_concurrent_parses: usizeParse jobs allowed to run at once (IFC_MAX_CONCURRENT_PARSES,
default = worker_threads). The admission CPU gate.
mem_budget_mb: usizeTotal upload bytes (in MB) allowed to be admitted at once
(IFC_MEM_BUDGET_MB). Default: auto-detected from the cgroup memory
limit (70% of it) when readable, else 0 = memory gate disabled.
admission_queue_depth: usizeRequests allowed to wait for an admission permit before immediate
rejection (IFC_ADMISSION_QUEUE_DEPTH, default = 2 * worker_threads).
admission_queue_timeout_secs: u64Longest a queued request waits for a permit, seconds
(IFC_ADMISSION_QUEUE_TIMEOUT_SECS, default 5).
mem_shed_pct: u8RSS high-water percentage of the memory budget above which new parse
jobs are shed (IFC_MEM_SHED_PCT, default 85).
metrics_enabled: boolExpose GET /api/v1/metrics (IFC_METRICS_ENABLED, default false).
Protected by the bearer token when one is configured.
api_token: Option<String>Optional bearer token for the compute/parse routes.
Read from IFC_SERVER_API_TOKEN (falling back to API_TOKEN). When set,
the parse/cache routes require an Authorization: Bearer <token> header
and return 401 otherwise. When unset (the default), those routes stay
open so the public viewer -> server flow keeps working, and the server
logs a startup warning that it is unauthenticated. The health endpoint is
always open regardless of this setting (liveness probes).
Implementations§
Source§impl Config
impl Config
Sourcepub(crate) fn from_lookup(get: impl Fn(&str) -> Option<String>) -> Self
pub(crate) fn from_lookup(get: impl Fn(&str) -> Option<String>) -> Self
The actual parsing, over an injected variable lookup.
Split out from Self::from_env purely so the defaults and the
parse/clamp rules are unit-testable without mutating the process
environment — from_env is called from other tests in this binary
(parity_tests::test_state), so a test that set IFC_SERVER_API_TOKEN
globally would silently switch those tests to an authenticated server.
Behavior is unchanged: from_env passes the real std::env::var.
pub(crate) so tests outside this module (cors_tests) can build a
config that is pinned to the shipped defaults rather than to whatever
the CI runner happens to export.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreSource§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.