pub struct ZeroOptions {Show 22 fields
pub cache_url: Option<String>,
pub user_id: Option<String>,
pub auth: Option<String>,
pub storage_key: Option<String>,
pub ping_timeout_ms: f64,
pub disconnect_timeout_ms: f64,
pub query_change_throttle_ms: f64,
pub max_header_length: usize,
pub mutate_url: Option<String>,
pub mutate_headers: Option<Vec<(String, String)>>,
pub query_url: Option<String>,
pub query_headers: Option<Vec<(String, String)>>,
pub on_update_needed: Option<UpdateNeededHandler>,
pub on_client_state_not_found: Option<Rc<dyn Fn()>>,
pub storage: ZeroStorage,
pub on_storage_failure: Option<StorageFailureHandler>,
pub log_level: LogLevel,
pub log_sink: Option<Rc<dyn LogSink>>,
pub hidden_disconnect_delay_ms: f64,
pub get_traceparent: Option<Rc<dyn Fn() -> Option<String>>>,
pub batch_view_updates: Option<BatchViewUpdates>,
pub slow_materialize_threshold_ms: f64,
}Expand description
The options of a Zero client (ZeroOptions in
packages/zero-client/src/client/options.ts).
Fields§
§cache_url: Option<String>The zero-cache URL, http or https. Without one the client runs
locally and never connects.
user_id: Option<String>The user the client syncs for. None for a logged-out client.
auth: Option<String>The auth token zero-cache and the API server see.
storage_key: Option<String>Distinguishes local stores of the same user and URLs.
ping_timeout_ms: f64How long the client waits for a pong before it reconnects.
disconnect_timeout_ms: f64How long the client tries to reconnect before the state is
Disconnected.
query_change_throttle_ms: f64How long query changes are batched before they are sent.
max_header_length: usizeThe longest Sec-WebSocket-Protocol header the client sends.
initConnection is sent as a message instead when it doesn’t fit.
mutate_url: Option<String>The API server’s push URL, when it differs from the one zero-cache is configured with.
mutate_headers: Option<Vec<(String, String)>>Headers zero-cache sends to mutate_url.
query_url: Option<String>The API server’s query URL, when it differs from the one zero-cache is configured with.
query_headers: Option<Vec<(String, String)>>Headers zero-cache sends to query_url.
on_update_needed: Option<UpdateNeededHandler>The server needs a newer client. Defaults to doing nothing.
on_client_state_not_found: Option<Rc<dyn Fn()>>The server no longer has the client’s state, or the stored replica
didn’t decode and the local store was reset. Without it, a client
the server lost replaces itself by a new one on the same store, as
JS reloads the page (see Zero::new).
storage: ZeroStorageWhere the client keeps its replica. Defaults to
ZeroStorage::Memory, which keeps nothing across restarts.
on_storage_failure: Option<StorageFailureHandler>The local store failed, so the client runs on what it has in memory
and persists nothing more (onStorageFailure). Called once.
log_level: LogLevelThe least severe messages logged.
log_sink: Option<Rc<dyn LogSink>>Where messages are logged. Defaults to StderrLogSink.
How long the app is hidden before the client disconnects
(hiddenTabDisconnectDelay); see Zero::set_visible.
get_traceparent: Option<Rc<dyn Fn() -> Option<String>>>A W3C traceparent for each query change and push the client sends
(getTraceparent), so zero-cache and the API server can join the
app’s trace. Called once per message; None sends none.
batch_view_updates: Option<BatchViewUpdates>Wraps every update of the views (batchViewUpdates), for a UI that
renders a batch of state changes at once: each new view’s creation,
and each change that updates the views (a poke, a mutation, the
first hydration), with its listener calls. It must call the function
it is given, once, before it returns.
slow_materialize_threshold_ms: f64How long, in ms, a query may take to materialize, including the
server’s and the network’s time, before the client logs a warning
(slowMaterializeThreshold). Faster materializations are logged at
debug level.