View Source EdgeDB.Client (EdgeDB v0.7.0)

Сlient is a structure that stores a custom configuration to execute EdgeQL queries and has a reference to a connection or pool of connections.

After starting the pool via EdgeDB.start_link/1 or siblings, the client instance for the pool will be implicitly registered.

In case you want to change the behavior of your queries, you will use the EdgeDB.Client, which is acceptable by all EdgeDB API and will be provided to you in a callback in the EdgeDB.transaction/3 function.

Summary

Types

Options for transactions and read-only queries retries.

Options for a retry rule for transactions retries.

t()

Client is structure with stored configuration for executing EdgeQL queries and reference to pool or connection.

Options for EdgeDB transactions.

Types

@type retry_option() ::
  {:transaction_conflict, retry_rule()} | {:network_error, retry_rule()}

Options for transactions and read-only queries retries.

See EdgeDB.transaction/3.

Supported options:

  • :transaction_conflict - the rule that will be used in case of any transaction conflict.
  • :network_error - rule which will be used when any network error occurs on the client.
@type retry_rule() ::
  {:attempts, pos_integer()} | {:backoff, (pos_integer() -> timeout())}

Options for a retry rule for transactions retries.

See EdgeDB.transaction/3.

Supported options:

  • :attempts - the number of attempts to retry the transaction in case of an error.
  • :backoff - function to determine the backoff before the next attempt to run a transaction.
@type t() :: %EdgeDB.Client{
  conn: DBConnection.conn(),
  readonly: boolean(),
  retry_options: [retry_option()],
  state: EdgeDB.Client.State.t(),
  transaction_options: [transaction_option()]
}

Client is structure with stored configuration for executing EdgeQL queries and reference to pool or connection.

Fields:

  • :conn - reference to connection or pool of connections.
  • :readonly - flag specifying that the client is read-only.
  • :transaction_options - options for EdgeDB transactions.
  • :retry_options - options for a retry rule for transactions retries.
  • :state - execution context that affects the execution of EdgeQL commands.
@type transaction_option() ::
  {:isolation, :serializable}
  | {:readonly, boolean()}
  | {:deferrable, boolean()}

Options for EdgeDB transactions.

These options are responsible for building the appropriate EdgeQL statement to start transactions and they correspond to the EdgeQL transaction statement.

Supported options:

  • :isolation - If :serializable is used, the built statement will use the isolation serializable mode. Currently only :serializable is supported by this client and EdgeDB.
  • :readonly - if set to true then the built statement will use read only mode, otherwise read write will be used. The default is false.
  • :deferrable - if set to true then the built statement will use deferrable mode, otherwise not deferrable will be used. The default is false.