Config

Struct Config 

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

Port to listen on.

§cache_dir: String

Directory for cache storage.

§max_file_size_mb: usize

Maximum file size in MB.

§request_timeout_secs: u64

Request timeout in seconds.

§stream_idle_timeout_secs: u64

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

Number of worker threads for parallel processing.

§initial_batch_size: usize

Initial batch size for fast first frame (first 3 batches).

§max_batch_size: usize

Maximum batch size for throughput (batches 11+).

§cache_max_age_days: u64

Maximum cache age in days.

§cors_origins: Vec<String>

Allowed CORS origins (comma-separated, or “*” for all in development).

§max_concurrent_parses: usize

Parse jobs allowed to run at once (IFC_MAX_CONCURRENT_PARSES, default = worker_threads). The admission CPU gate.

§mem_budget_mb: usize

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

Requests allowed to wait for an admission permit before immediate rejection (IFC_ADMISSION_QUEUE_DEPTH, default = 2 * worker_threads).

§admission_queue_timeout_secs: u64

Longest a queued request waits for a permit, seconds (IFC_ADMISSION_QUEUE_TIMEOUT_SECS, default 5).

§mem_shed_pct: u8

RSS high-water percentage of the memory budget above which new parse jobs are shed (IFC_MEM_SHED_PCT, default 85).

§metrics_enabled: bool

Expose 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

Source

pub fn from_env() -> Self

Load configuration from environment variables.

Source

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§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

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 Config

Source§

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

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

impl Default for Config

Source§

fn default() -> Self

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

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§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<U> As for U

§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts 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 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.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,