SurrealClientConfig configures a SurrealClient. The only required field is url; everything else has a sensible default.
Source: surrealdb.kotlin
Fields
| Field | Type | Default | Description |
|---|---|---|---|
url | String | — | The connection URL. The scheme (ws/wss/http/https) selects the transport. |
json | Json | lenient | The kotlinx.serialization instance used for encoding and decoding. |
autoConnect | Boolean | true | Connect lazily on the first request. |
autoAuthenticate | Boolean | false | Authenticate automatically using credentialProvider on connect and reconnect. |
credentialProvider | (suspend () -> SurrealAuthInput?)? | null | Supplies credentials for automatic authentication and token renewal. |
requestTimeoutMillis | Long | 30_000 | Per-request timeout in milliseconds. |
reconnect | ReconnectConfig | ReconnectConfig() | WebSocket reconnection behaviour. |
tokenRenewalLeadMillis | Long | 60_000 | How long before token expiry to renew, in milliseconds. |
httpClientFactory | ((SurrealClientConfig) -> HttpClient)? | null | Supplies a custom Ktor HttpClient. |
ReconnectConfig
Controls exponential-backoff reconnection on the WebSocket transport.
| Field | Type | Default | Description |
|---|---|---|---|
enabled | Boolean | true | Whether reconnection is attempted. |
initialDelayMillis | Long | 250 | Delay before the first retry. |
maxDelayMillis | Long | 30_000 | Maximum delay between retries. |
multiplier | Double | 1.5 | Backoff multiplier applied each attempt. |
maxAttempts | Int? | null | Maximum attempts; null retries indefinitely. |
SurrealAuthInput
A sealed interface describing how credentialProvider should authenticate.
| Variant | Payload | Description |
|---|---|---|
SurrealAuthInput.SignIn | params: JsonObject | Sign in with credentials. |
SurrealAuthInput.Token | token: String | Authenticate with an existing token. |