freddy v0.15.1 Freddy.Adapter behaviour

An interface for AMQP layer

Link to this section Summary

Callbacks

Binds given exchange to another exchange

Closes existing channel

Closes AMQP connection

Registers given pid as a consumer from a queue

Declares exchange of the given type on the channel

Declares queue with the given name on the channel

Transforms a message received by a consumed pid into one of the well defined terms expected by consumers. The expected terms are:

  • {:consume_ok, meta} - consume-ok message sent by the AMQP server when a consumer is started
  • {:deliver, payload, meta} - an actual message from the queue being consumed
  • {:cancel_ok, meta} - cancel-ok message sent by the AMQP server when a consumer is started
  • {:cancel, meta} - cancel message sent by the AMQP server when a consumer has been unexpectedly closed
  • {:return, payload meta} - return message sent by the AMQP server when message could not be routed
  • :unknown - any other message

Links current process to a connection

Sets up a monitor on a channel

Opens new channel on connection

Opens AMQP connection with given options. Return {:ok, connection} on success or {:error, reason} on failure

Set up channel QoS

Registers given process as a return handler for the given channel

Unbinds given queue to the exchange

Link to this section Types

Link to this type

channel()
channel() :: pid()

Link to this type

connection()
connection() :: pid()

Link to this type

consumer_tag()
consumer_tag() :: String.t()

Link to this type

delivery_tag()
delivery_tag() :: String.t()

Link to this type

error()
error() :: atom()

Link to this type

exchange_name()
exchange_name() :: String.t()

Link to this type

exchange_type()
exchange_type() :: atom() | String.t()

Link to this type

meta()
meta() :: map()

Link to this type

options()
options() :: Keyword.t()

Link to this type

payload()
payload() :: String.t()

Link to this type

queue_name()
queue_name() :: String.t()

Link to this type

queue_opts()
queue_opts() :: Keyword.t()

Link to this type

routing_key()
routing_key() :: String.t()

Link to this section Callbacks

Link to this callback

ack(channel, delivery_tag, options)
ack(channel(), delivery_tag(), options()) :: :ok | {:error, error()}

Acks a message

Link to this callback

bind_exchange(channel, destination, source, options)
bind_exchange(
  channel(),
  destination :: exchange_name(),
  source :: exchange_name(),
  options()
) :: :ok | {:error, error()}

Binds given exchange to another exchange

Link to this callback

bind_queue(channel, queue_name, exchange_name, options)
bind_queue(channel(), queue_name(), exchange_name(), options()) ::
  :ok | {:error, error()}

Binds given queue to the exchange

Link to this callback

close_channel(channel)
close_channel(channel()) :: :ok | {:error, error()}

Closes existing channel

Link to this callback

close_connection(connection)
close_connection(connection()) :: :ok | {:error, error()}

Closes AMQP connection

Link to this callback

consume(channel, queue_name, consumer, options)
consume(channel(), queue_name(), consumer :: pid(), options()) ::
  {:ok, consumer_tag()} | {:error, error()}

Registers given pid as a consumer from a queue

Link to this callback

declare_exchange(channel, exchange_name, exchange_type, options)
declare_exchange(channel(), exchange_name(), exchange_type(), options()) ::
  :ok | {:error, error()}

Declares exchange of the given type on the channel

Link to this callback

declare_queue(channel, queue_name, options)
declare_queue(channel(), queue_name(), options()) ::
  {:ok, queue_name()} | {:error, error()}

Declares queue with the given name on the channel

Link to this callback

delete_queue(channel, queue_name, options)
delete_queue(channel(), queue_name(), options()) ::
  {:ok, meta()} | {:error, error()}

Deletes the given queue

Link to this callback

handle_message(message)
handle_message(message :: term()) ::
  {:consume_ok, meta()}
  | {:deliver, payload(), meta()}
  | {:cancel_ok, meta()}
  | {:cancel, meta()}
  | {:return, payload(), meta()}
  | :unknown

Transforms a message received by a consumed pid into one of the well defined terms expected by consumers. The expected terms are:

  • {:consume_ok, meta} - consume-ok message sent by the AMQP server when a consumer is started
  • {:deliver, payload, meta} - an actual message from the queue being consumed
  • {:cancel_ok, meta} - cancel-ok message sent by the AMQP server when a consumer is started
  • {:cancel, meta} - cancel message sent by the AMQP server when a consumer has been unexpectedly closed
  • {:return, payload meta} - return message sent by the AMQP server when message could not be routed
  • :unknown - any other message
Link to this callback

monitor_channel(channel)
monitor_channel(channel()) :: reference()

Sets up a monitor on a channel

Link to this callback

nack(channel, delivery_tag, options)
nack(channel(), delivery_tag(), options()) :: :ok | {:error, error()}

Nacks a message

Link to this callback

open_channel(connection)
open_channel(connection()) :: {:ok, channel()} | {:error, error()}

Opens new channel on connection

Link to this callback

open_connection(arg0)
open_connection(options() | String.t()) ::
  {:ok, connection()} | {:error, error()}

Opens AMQP connection with given options. Return {:ok, connection} on success or {:error, reason} on failure.

Link to this callback

publish(channel, exchange_name, routing_key, payload, options)
publish(channel(), exchange_name(), routing_key(), payload(), options()) ::
  :ok | {:error, error()}

Publishes a message to an exchange

Link to this callback

qos(channel, options)
qos(channel(), options :: Keyword.t()) :: :ok | {:error, error()}

Set up channel QoS

Link to this callback

register_return_handler(channel, pid)
register_return_handler(channel(), pid()) :: :ok

Registers given process as a return handler for the given channel

Link to this callback

reject(channel, delivery_tag, options)
reject(channel(), delivery_tag(), options()) :: :ok | {:error, error()}

Rejects a message

Link to this callback

unbind_queue(channel, queue_name, exchange_name, options)
unbind_queue(channel(), queue_name(), exchange_name(), options()) ::
  :ok | {:error, error()}

Unbinds given queue to the exchange