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: usizeGlobal 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: usizeIn-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: usizeIn-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: boolRequest zrip compression from the server / compress uploads.
chunk_size: u64Fixed 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: u32Maximum retries per chunk/file (default 3).
base_retry_delay_ms: u32Initial backoff delay in ms (default 500).
max_retry_delay_ms: u32Backoff ceiling in ms (default 30s).
timeout_ms: u32Per-request timeout in ms (default 60s).
auto_tune: boolAdaptive 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: u64How long a cached tuning result stays usable (milliseconds, default
1 hour). 0 disables the cache entirely — every transfer re-ramps.
compress_level: CompressLevelClient-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
impl ClientConfig
Sourcepub fn request_budget(&self) -> usize
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
impl ClientConfig
Sourcepub fn from_js(opts: &JsValue) -> ClientConfig
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.
Sourcepub fn backoff_ms(&self, attempt: u32) -> u32
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.