Arangox v0.2.1 Arangox.Client behaviour View Source

HTTP client behaviour for Arangox.

To use an http library other than :gun or Mint, implement this behaviour in a module and pass that module to the :client start option. Arangox will use that implementation to perform all it's http related connection and execution operations.

Link to this section Summary

Callbacks

Receives a raw endpoint binary and all the start options from Arangox.start_link/1.

Receives a Arangox.Request struct and a connection's state, an Arangox.Connection struct, and returns an Arangox.Response struct or error (or exception struct), along with the new state.

Link to this section Types

Link to this type

exception_or_reason()

View Source
exception_or_reason() :: any()
Link to this type

start_options()

View Source
start_options() :: [Arangox.start_option()]
Link to this type

state()

View Source
state() :: Arangox.Connection.t()

Link to this section Functions

Link to this section Callbacks

Link to this callback

close(state)

View Source
close(state()) :: :ok
Link to this callback

connect(endpoint, start_options)

View Source
connect(endpoint(), start_options()) ::
  {:ok, conn()} | {:error, exception_or_reason()}

Receives a raw endpoint binary and all the start options from Arangox.start_link/1.

The Arangox.Endpoint module has utilities for parsing ArangoDB endpoints. The conn returned from this callback gets placed in the :socket field of an %Arango.Connection{} struct, which represents a connection's state.

It's up to the client to consolidate the :connect_timeout, :transport_opts and :client_opts options.

Link to this callback

request(request, state)

View Source
request(request(), state()) ::
  {:ok, response(), state()} | {:error, exception_or_reason(), state()}

Receives a Arangox.Request struct and a connection's state, an Arangox.Connection struct, and returns an Arangox.Response struct or error (or exception struct), along with the new state.

Arangox handles the encoding and decoding of request and response bodies.

In the case of an error, this should return {:error, :noproc, state} if the connection was lost, otherwise an attempt to reconnect won't be made until the next request hitting this process fails.