Skip to main content

ClientConfig

Struct ClientConfig 

Source
pub struct ClientConfig {
    pub concurrency: usize,
    pub upload_window: usize,
    pub download_window: usize,
    pub compress: bool,
    pub chunk_size: u64,
    pub max_retries: u32,
    pub base_retry_delay_ms: u32,
    pub max_retry_delay_ms: u32,
    pub timeout_ms: u32,
    pub auto_tune: bool,
    pub tune_ttl_ms: u64,
    pub compress_level: CompressLevel,
}
Expand description

Runtime configuration of the WASM engine.

Fields§

§concurrency: usize

Global cap on concurrent in-flight HTTP transfers (default 4).

Every upload chunk POST and download range GET acquires a permit from a shared pool, so this bounds the engine’s TOTAL network parallelism — across all files AND all per-file windows combined (a single file can still open up to upload_window / download_window requests, but never more than concurrency in total).

§upload_window: usize

In-flight chunk window for a single file’s upload (default 8).

Independent of concurrency: one file keeps up to upload_window chunks in flight, so a high-latency link stays saturated (throughput is bounded by bandwidth, not chunk_size / RTT).

§download_window: usize

In-flight byte-range window for a single file’s download (default 4).

A large file is downloaded as download_window concurrent Range GETs so its throughput is bounded by bandwidth instead of one connection’s chunk_size / RTT (tus-style parallel transfer). Set to 1 to fall back to the sequential single-connection path.

§compress: bool

Request zrip compression from the server / compress uploads.

§chunk_size: u64

Fixed chunk size used to slice files and byte-range downloads (default 2 MiB).

The same value is used for both upload chunking and parallel download range splits, so a single config option represents the budget for both paths (larger = fewer, bigger transfers; bounded by the server’s upload limit, memory, and the per-file window budget).

§max_retries: u32

Maximum retries per chunk/file (default 3).

§base_retry_delay_ms: u32

Initial backoff delay in ms (default 500).

§max_retry_delay_ms: u32

Backoff ceiling in ms (default 30s).

§timeout_ms: u32

Per-request timeout in ms (default 60s).

§auto_tune: bool

Adaptive tuning (TCP-style ramp over real transfers), off by default.

Opting in is what makes the engine measure the link: without it the knobs below are used exactly as configured.

In the browser a settled result is persisted in localStorage (per origin + direction) for up to tune_ttl_ms, so a page refresh does not re-ramp; the native client keeps it in memory only.

§tune_ttl_ms: u64

How long a cached tuning result stays usable (milliseconds, default 1 hour). 0 disables the cache entirely — every transfer re-ramps.

§compress_level: CompressLevel

Client-side compression level policy, defaulting to CompressLevel::Balanced.

Absent config resolves to whatever the server advertises as its own default level, so a client that never sets the field negotiates the server’s choice. compress: false still forces identity regardless of this field.

Implementations§

Source§

impl ClientConfig

Source

pub fn request_budget(&self) -> usize

Concurrent HTTP requests the client may keep in flight: concurrency files × the widest per-file window.

The pool is a bound, not the parallelism knob: sized to concurrency alone it would clamp every file to one request and make the per-file window ineffective (see tune::request_budget).

Source§

impl ClientConfig

Source

pub fn from_js(opts: &JsValue) -> ClientConfig

Parse configuration from a JS object literal, e.g. { concurrency: 4, compress: true, chunkSize: 2097152 }.

Safe to call with null/undefined (returns defaults) — this also keeps native (non-wasm) unit tests runnable.

Source

pub fn backoff_ms(&self, attempt: u32) -> u32

Exponential backoff delay for a failed attempt (0-based).

2^attempt * base, clamped to max. Bounded so a hung peer cannot grow the delay without limit.

Trait Implementations§

Source§

impl Clone for ClientConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ClientConfig

Source§

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

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

impl Default for ClientConfig

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> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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