Rambla v0.1.0 Rambla.Connection behaviour View Source

The default behaviour for publishers. The common use case would be the module implementing this behaviour opens a connection (and keep it opened,) and publishes messages as needed.

Link to this section Summary

Types

The response type; contains a status and a response from remote service

t()

The connection information

Functions

Returns a specification to start this module under a supervisor.

Publishes a message to the connection established.

Accepts options for the underlying connection (those will be passed to connect/1.)

Callbacks

Connects to the remote service and returns a connection object back

Publishes the message to the remote service using connection provided

Link to this section Types

Link to this type

outcome()

View Source
outcome() :: {:ok | :error, Rambla.Exception.t() | any()}

The response type; contains a status and a response from remote service

Link to this type

t()

View Source
t() :: %Rambla.Connection{
  conn: any(),
  conn_type: atom(),
  conn_params: keyword(),
  conn_pid: pid(),
  errors: [Rambla.Exception.t()]
}

The connection information

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

handle_call(msg, arg2, state)

View Source

Publishes a message to the connection established.

Expects the following options to be passed:

%{
  queue: "queue-name",
  exchange: "exchange-name"
}

Returns {:ok, response} or {:error, reason}.

Accepts options for the underlying connection (those will be passed to connect/1.)

Link to this section Callbacks

Link to this callback

connect(params)

View Source
connect(params :: keyword()) :: t()

Connects to the remote service and returns a connection object back

Link to this callback

publish(conn, message)

View Source
publish(conn :: any(), message :: map()) :: outcome()

Publishes the message to the remote service using connection provided