Configuration for a client. The options provided are used as the default options for each query.

interface ClientConfiguration {
    client_timeout_buffer_ms?: number;
    endpoint?: URL;
    fetch_keepalive?: boolean;
    format?: ValueFormat;
    http2_max_streams?: number;
    http2_session_idle_ms?: number;
    linearized?: boolean;
    long_type?: "number" | "bigint";
    max_attempts?: number;
    max_backoff?: number;
    max_contention_retries?: number;
    query_tags?: {
        [key: string]: string;
    };
    query_timeout_ms?: number;
    secret?: string;
    traceparent?: string;
    typecheck?: boolean;
}

Properties

client_timeout_buffer_ms?: number

Time in milliseconds beyond ClientConfiguration.query_timeout_ms at which the client will abort a request if it has not received a response. The default is 5000 ms, which should account for network latency for most clients. The value must be greater than zero. The closer to zero the value is, the more likely the client is to abort the request before the server can report a legitimate response or error.

endpoint?: URL

The URL of Fauna to call. See endpoints for some default options.

fetch_keepalive?: boolean

When true will keep executing a request even if the page that fired the request is no longer executing. Only relevant to underlying clients using the Fetch standard. By default set to false.

Relevant to clients using the FetchClient provided, or any custom HTTP Clients you implement using the Fetch standard.

format?: ValueFormat

Determines the encoded format expected for the query arguments field, and the data field of a successful response.

Note, it is very unlikely you need to change this value from its default. The default format is "tagged", which specifies that the driver transmits type information over the wire. Type information allows the driver and Fauna to distinguish between types such as int" and "long" which do not have a standard way of distinguishing in JSON. Rare use cases can also deal with standard JSON by setting the value to "simple". Note that the types enocodable in standard JSON are a subset of the types encodable in the default "tagged" format. It is not recommended that users use the "simple" format as you will lose the typing of your data. e.g. a "Date" will no longer be recognized by the Fauna as a "Date", but will instead be treated as a string.

http2_max_streams?: number

The maximum number of HTTP2 streams to execute in parallel to Fauna per HTTP2 session. Only relevant to certain HTTP2 clients.

Relevant to clients using the NodeHTTP2Client provided, or any custom HTTP2Clients you implement that support this feature.

http2_session_idle_ms?: number

Time in milliseconds the client will keep an HTTP2 session open after all requests are completed. The default is 5000 ms.

linearized?: boolean

If true, unconditionally run the query as strictly serialized. This affects read-only transactions. Transactions which write will always be strictly serialized.

long_type?: "number" | "bigint"

Controls what Javascript type to deserialize Fauna longs to. Use 'number' to deserialize longs to number. Use 'bigint' to deserialize to bigint. Defaults to 'number'. Note, for extremely large maginitude numbers Javascript's number will lose precision; as Javascript's 'number' can only support +/- 2^53-1 whereas Fauna's long is 64 bit. If this is detected, a warning will be logged to the console and precision loss will occur. If your application uses extremely large magnitude numbers use 'bigint'.

max_attempts?: number

Max attempts for retryable exceptions. Default is 3.

max_backoff?: number

Max backoff between retries. Default is 20 seconds.

max_contention_retries?: number

The max number of times to retry the query if contention is encountered.

query_tags?: {
    [key: string]: string;
}

Tags provided back via logging and telemetry.

query_timeout_ms?: number

The timeout of each query, in milliseconds. This controls the maximum amount of time Fauna will execute your query before marking it failed. The default is 5000 ms.

secret?: string

A secret for your Fauna DB, used to authorize your queries.

traceparent?: string

A traceparent provided back via logging and telemetry. Must match format: https://www.w3.org/TR/trace-context/#traceparent-header

typecheck?: boolean

Enable or disable typechecking of the query before evaluation. If no value is provided, the value of typechecked in the database configuration will be used.