View Source Rambla.Connection behaviour (Rambla v1.2.6)

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.


Rambla.Connection supports options: config that will be passed directly to :poolboy as Options.

Example

config :rambla,
  amqp: []
  pools: [amqp: [options: [size: 2, max_overflow: 1], ]]

Summary

Types

The accepted type of the message to be published

The response type for the single request. Contains a status and a response from remote service

The response type for the bulk request. Contains a status and a response from remote service

t()

The connection information

Callbacks

Connects to the remote service and returns a connection object back

Publishes the message to the remote service using connection provided

Functions

Returns a specification to start this module under a supervisor.

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

Types

@type message() :: binary() | Enum.t()

The accepted type of the message to be published

@type messages() :: [message()]
@type outcome() :: {:ok | :error, Rambla.Exception.t() | any()}

The response type for the single request. Contains a status and a response from remote service

@type outcomes() :: %{oks: [any()], errors: [Rambla.Exception.t()]}

The response type for the bulk request. Contains a status and a response from remote service

@type t() :: %Rambla.Connection{
  conn: Rambla.Connection.Config.t(),
  conn_params: keyword(),
  conn_type: atom(),
  conn_pid: pid(),
  opts: map(),
  errors: [Rambla.Exception.t()]
}

The connection information

Callbacks

@callback connect(params :: keyword()) :: t()

Connects to the remote service and returns a connection object back

@callback publish(conn :: any(), message :: message()) :: outcome()

Publishes the message to the remote service using connection provided

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

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