Gel.Client (Gel v0.9.0)

View Source

С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 Gel.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 Gel.Client, which is acceptable by all Gel API and will be provided to you in a callback in the Gel.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 Gel transactions.

Types

retry_option()

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

Options for transactions and read-only queries retries.

See Gel.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.

retry_rule()

@type retry_rule() ::
  {:attempts, pos_integer()} | {:backoff, (pos_integer() -> timeout())}

Options for a retry rule for transactions retries.

See Gel.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.

t()

@type t() :: %Gel.Client{
  conn: DBConnection.conn(),
  readonly: boolean(),
  retry_options: [retry_option()],
  state: Gel.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 Gel transactions.
  • :retry_options - options for a retry rule for transactions retries.
  • :state - execution context that affects the execution of EdgeQL commands.

transaction_option()

@type transaction_option() ::
  {:isolation, :serializable}
  | {:readonly, boolean()}
  | {:deferrable, boolean()}

Options for Gel 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 Gel.
  • :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.