Freddy.Adapter behaviour (freddy v0.17.0-rc.5)

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

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

Specs

channel() :: pid()
Link to this type

connection()

Specs

connection() :: pid()
Link to this type

consumer_tag()

Specs

consumer_tag() :: String.t()
Link to this type

delivery_tag()

Specs

delivery_tag() :: String.t()

Specs

error() :: atom()
Link to this type

exchange_name()

Specs

exchange_name() :: String.t()
Link to this type

exchange_type()

Specs

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

Specs

meta() :: map()

Specs

options() :: Keyword.t()

Specs

payload() :: String.t()
Link to this type

queue_name()

Specs

queue_name() :: String.t()
Link to this type

queue_opts()

Specs

queue_opts() :: Keyword.t()
Link to this type

routing_key()

Specs

routing_key() :: String.t()

Link to this section Callbacks

Link to this callback

ack(channel, delivery_tag, options)

Specs

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

Acks a message

Link to this callback

bind_exchange(channel, destination, source, options)

Specs

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)

Specs

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

Binds given queue to the exchange

Link to this callback

close_channel(channel)

Specs

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

Closes existing channel

Link to this callback

close_connection(connection)

Specs

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

Closes AMQP connection

Link to this callback

consume(channel, queue_name, consumer, options)

Specs

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)

Specs

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)

Specs

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)

Specs

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

Deletes the given queue

Link to this callback

handle_message(message)

Specs

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)

Specs

monitor_channel(channel()) :: reference()

Sets up a monitor on a channel

Link to this callback

nack(channel, delivery_tag, options)

Specs

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

Nacks a message

Link to this callback

open_channel(connection)

Specs

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

Opens new channel on connection

Link to this callback

open_connection(arg1)

Specs

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)

Specs

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

Publishes a message to an exchange

Link to this callback

qos(channel, options)

Specs

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

Set up channel QoS

Link to this callback

register_return_handler(channel, pid)

Specs

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)

Specs

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

Rejects a message

Link to this callback

unbind_queue(channel, queue_name, exchange_name, options)

Specs

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

Unbinds given queue to the exchange