Options

data class Options(val key: String = UUID.randomUUID().toString(), val apiKey: String? = null, val metadata: Map<String, String> = emptyMap(), val fetchAuthToken: suspend (shouldRefresh: Boolean) -> String? = null, val syncLoopDuration: Duration = 50.milliseconds, val reconnectStreamDelay: Duration = 1_000.milliseconds, val channelHeartbeatInterval: Duration = 5_000.milliseconds, val documentPollInterval: Duration = 3_000.milliseconds, val watchFallbackDelay: Duration = 10_000.milliseconds)

User-settable options used when defining Client.

Constructors

Link copied to clipboard
constructor(key: String = UUID.randomUUID().toString(), apiKey: String? = null, metadata: Map<String, String> = emptyMap(), fetchAuthToken: suspend (shouldRefresh: Boolean) -> String? = null, syncLoopDuration: Duration = 50.milliseconds, reconnectStreamDelay: Duration = 1_000.milliseconds, channelHeartbeatInterval: Duration = 5_000.milliseconds, documentPollInterval: Duration = 3_000.milliseconds, watchFallbackDelay: Duration = 10_000.milliseconds)

Properties

Link copied to clipboard
val apiKey: String? = null

API key of the project used to identify the project.

Link copied to clipboard

channelHeartbeatInterval is the interval of the channel heartbeat. The client sends a heartbeat to the server to refresh the channel TTL. Applies to both Realtime and Manual/Polling channels. The default value is 5000(ms) — TTL/3 for the server's 15s ChannelSessionTTL. Mirrors JS SDK v0.7.10.

Link copied to clipboard

documentPollInterval is the push-pull interval for documents attached with SyncMode.Polling. Unused in other sync modes. The default value is 3000(ms). Mirrors JS SDK PR #1243.

Link copied to clipboard
val fetchAuthToken: suspend (shouldRefresh: Boolean) -> String? = null

fetchAuthToken provides a token for the auth webhook. When the webhook response status code is 401, this function is called to refresh the token. The reason parameter is the reason from the webhook response.

Link copied to clipboard
val key: String

Client key used to identify the client. If not set, a random key is generated.

Link copied to clipboard

metadata is the metadata of the client. It is used to store additional information about the client.

Link copied to clipboard

Delay of the reconnect stream. If the stream is disconnected, the client waits for the delay to reconnect the stream. The default value is 1000(ms).

Link copied to clipboard

Duration of the sync loop. After each sync loop, the client waits for the duration to next sync. The default value is 50(ms).

Link copied to clipboard

watchFallbackDelay is how long a realtime document's watch stream may stay silent (no frame of any kind received) before that attachment starts pulling on every sync-loop tick (throttled to documentPollInterval) as if it were Polling — i.e. degrades toward polling semantics per-attachment until a watch frame arrives again. This bounds staleness instead of the permanent pull starvation a silently-dead watch stream otherwise causes (a dead watch stream never flips changeEventReceived, so pull would never re-engage on its own — see #351).