bricks v0.1.0 Bricks.Connector behaviour View Source

A struct, behaviour and functions for working with Socket Connectors

Link to this section Summary

Types

A function which borrows a Socket

State passed to the underlying Connector

t()

A Socket Connector

Functions

Attempts to create a connected Socket with the provided Connector

Calls the provided function with a Socket leased from the provided pool

Creates a new Connector from a callback module and a connector object

Callbacks

Create a Socket according to the configuration state

Link to this section Types

Link to this type lessee() View Source
lessee() :: (Bricks.Socket.t() -> {:ok, term()} | {:error, term()})

A function which borrows a Socket

State passed to the underlying Connector

Link to this type t() View Source
t() :: %Bricks.Connector{connector: term(), module: atom()}

A Socket Connector

Link to this section Functions

Link to this function connect(connector) View Source
connect(t()) :: {:ok, Bricks.Socket.t()} | {:error, term()}

Attempts to create a connected Socket with the provided Connector

Link to this function lease(conn, fun) View Source
lease(t(), lessee()) :: {:error, term()} | term()

Calls the provided function with a Socket leased from the provided pool

Returns the socket to the pool or burns it, depending on the return of the provided function.

In the event of error, burns the socket

Link to this function new(module, connector) View Source
new(atom(), term()) :: t()

Creates a new Connector from a callback module and a connector object

Link to this section Callbacks

Link to this callback connect(state) View Source
connect(state()) :: {:ok, Bricks.Socket.t()} | {:error, term()}

Create a Socket according to the configuration state