View Source Ravix.Connection.RequestExecutor (ravix v0.0.2)

A process responsible for executing requests to the RavenDB API

Each RavenDB cluster node has it's own stateful request executor, which holds how many requests this node executed, the address and infos from the Node and which requests are being executed in the moment.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Executes a RavenDB command for the informed connection

Executes a RavenDB command on the informed node

Fetches the current node executor state

Fetches the current node executor state

Initializes the connection for the informed ServerNode

Asynchronously updates the cluster tag for the current node

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

execute(command, conn_state, headers \\ {}, opts \\ [])

View Source
@spec execute(map(), Ravix.Connection.State.t(), any(), keyword()) ::
  {:error, any()} | {:ok, Ravix.Connection.Response.t()}

Executes a RavenDB command for the informed connection

parameters

Parameters

  • command: The command that will be executed, must be a RavenCommand
  • conn_state: The connection state for which this execution will be linked
  • headers: HTTP headers to send to RavenDB
  • opts: Request options

returns

Returns

  • {:ok, Ravix.Connection.Response} for a successful call
  • {:error, cause} if the request fails
Link to this function

execute_for_node(command, pid_or_url, database, headers \\ {}, opts \\ [])

View Source
@spec execute_for_node(map(), binary() | pid(), String.t() | nil, any(), keyword()) ::
  {:error, any()} | {:ok, Ravix.Connection.Response.t()}

Executes a RavenDB command on the informed node

parameters

Parameters

  • command: The command that will be executed, must be a RavenCommand
  • pid_or_url: The PID or the Url of the node where the command will be executed
  • database: The database name
  • headers: HTTP headers to send to RavenDB
  • opts: Request options

returns

Returns

  • {:ok, Ravix.Connection.Response} for a successful call
  • {:error, cause} if the request fails
@spec fetch_node_state(bitstring() | pid()) ::
  {:ok, Ravix.Connection.ServerNode.t()} | {:error, :node_not_found}

Fetches the current node executor state

parameters

Parameters

pid = The PID of the node

returns

Returns

  • {:ok, Ravix.Connection.ServerNode} if there's a node
  • {:error, :node_not_found} if there's not a node with the informed pid
Link to this function

fetch_node_state(url, database)

View Source
@spec fetch_node_state(binary(), binary()) ::
  {:ok, Ravix.Connection.ServerNode.t()} | {:error, :node_not_found}

Fetches the current node executor state

parameters

Parameters

url = The node url database = the node database name

returns

Returns

  • {:ok, Ravix.Connection.ServerNode} if there's a node
  • {:error, :node_not_found} if there's not a node with the informed pid
@spec init(Ravix.Connection.ServerNode.t()) ::
  {:ok, Ravix.Connection.ServerNode.t()}
  | {:stop,
     %{
       :__exception__ => any(),
       :__struct__ => Mint.HTTPError | Mint.TransportError,
       :reason => any(),
       optional(:module) => any()
     }}

Initializes the connection for the informed ServerNode

The process will take care of the connection state, if the connection closes, the process will die automatically

@spec start_link(any(), Ravix.Connection.ServerNode.t()) ::
  :ignore | {:error, any()} | {:ok, pid()}
Link to this function

update_cluster_tag(url, database, cluster_tag)

View Source
@spec update_cluster_tag(String.t(), String.t(), String.t()) :: :ok

Asynchronously updates the cluster tag for the current node

parameters

Parameters

  • url: Node url
  • database: Database name
  • cluster_tag: new cluster tag

returns

Returns

  • :ok