freddy v0.15.1 Freddy.Adapter behaviour
An interface for AMQP layer
Link to this section Summary
Callbacks
Acks a message
Binds given exchange to another exchange
Binds given queue to the 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
Deletes the given queue
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
Nacks a message
Opens new channel on connection
Opens AMQP connection with given options. Return {:ok, connection}
on success
or {:error, reason}
on failure
Publishes a message to an exchange
Set up channel QoS
Registers given process as a return handler for the given channel
Rejects a message
Unbinds given queue to the exchange
Link to this section Types
channel()
channel() :: pid()
channel() :: pid()
connection()
connection() :: pid()
connection() :: pid()
consumer_tag()
consumer_tag() :: String.t()
consumer_tag() :: String.t()
delivery_tag()
delivery_tag() :: String.t()
delivery_tag() :: String.t()
error()
error() :: atom()
error() :: atom()
exchange_name()
exchange_name() :: String.t()
exchange_name() :: String.t()
exchange_type()
meta()
meta() :: map()
meta() :: map()
options()
options() :: Keyword.t()
options() :: Keyword.t()
payload()
payload() :: String.t()
payload() :: String.t()
queue_name()
queue_name() :: String.t()
queue_name() :: String.t()
queue_opts()
queue_opts() :: Keyword.t()
queue_opts() :: Keyword.t()
routing_key()
routing_key() :: String.t()
routing_key() :: String.t()
Link to this section Callbacks
ack(channel, delivery_tag, options)
ack(channel(), delivery_tag(), options()) :: :ok | {:error, error()}
ack(channel(), delivery_tag(), options()) :: :ok | {:error, error()}
Acks a message
bind_exchange(channel, destination, source, options)
bind_exchange(
channel(),
destination :: exchange_name(),
source :: exchange_name(),
options()
) :: :ok | {:error, error()}
bind_exchange( channel(), destination :: exchange_name(), source :: exchange_name(), options() ) :: :ok | {:error, error()}
Binds given exchange to another exchange
bind_queue(channel, queue_name, exchange_name, options)
bind_queue(channel(), queue_name(), exchange_name(), options()) ::
:ok | {:error, error()}
bind_queue(channel(), queue_name(), exchange_name(), options()) :: :ok | {:error, error()}
Binds given queue to the exchange
close_channel(channel)
Closes existing channel
close_connection(connection)
close_connection(connection()) :: :ok | {:error, error()}
close_connection(connection()) :: :ok | {:error, error()}
Closes AMQP connection
consume(channel, queue_name, consumer, options)
consume(channel(), queue_name(), consumer :: pid(), options()) ::
{:ok, consumer_tag()} | {:error, error()}
consume(channel(), queue_name(), consumer :: pid(), options()) :: {:ok, consumer_tag()} | {:error, error()}
Registers given pid as a consumer from a queue
declare_exchange(channel, exchange_name, exchange_type, options)
declare_exchange(channel(), exchange_name(), exchange_type(), options()) ::
:ok | {:error, error()}
declare_exchange(channel(), exchange_name(), exchange_type(), options()) :: :ok | {:error, error()}
Declares exchange of the given type on the channel
declare_queue(channel, queue_name, options)
declare_queue(channel(), queue_name(), options()) ::
{:ok, queue_name()} | {:error, error()}
declare_queue(channel(), queue_name(), options()) :: {:ok, queue_name()} | {:error, error()}
Declares queue with the given name on the channel
delete_queue(channel, queue_name, options)
delete_queue(channel(), queue_name(), options()) ::
{:ok, meta()} | {:error, error()}
delete_queue(channel(), queue_name(), options()) :: {:ok, meta()} | {:error, error()}
Deletes the given queue
handle_message(message)
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_connection(connection)
link_connection(connection()) :: :ok
link_connection(connection()) :: :ok
Links current process to a connection
monitor_channel(channel)
Sets up a monitor on a channel
nack(channel, delivery_tag, options)
nack(channel(), delivery_tag(), options()) :: :ok | {:error, error()}
nack(channel(), delivery_tag(), options()) :: :ok | {:error, error()}
Nacks a message
open_channel(connection)
open_channel(connection()) :: {:ok, channel()} | {:error, error()}
open_channel(connection()) :: {:ok, channel()} | {:error, error()}
Opens new channel on connection
open_connection(arg0)
open_connection(options() | String.t()) ::
{:ok, connection()} | {:error, error()}
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.
publish(channel, exchange_name, routing_key, payload, options)
publish(channel(), exchange_name(), routing_key(), payload(), options()) ::
:ok | {:error, error()}
publish(channel(), exchange_name(), routing_key(), payload(), options()) :: :ok | {:error, error()}
Publishes a message to an exchange
qos(channel, options)
Set up channel QoS
register_return_handler(channel, pid)
Registers given process as a return handler for the given channel
reject(channel, delivery_tag, options)
reject(channel(), delivery_tag(), options()) :: :ok | {:error, error()}
reject(channel(), delivery_tag(), options()) :: :ok | {:error, error()}
Rejects a message
unbind_queue(channel, queue_name, exchange_name, options)
unbind_queue(channel(), queue_name(), exchange_name(), options()) ::
:ok | {:error, error()}
unbind_queue(channel(), queue_name(), exchange_name(), options()) :: :ok | {:error, error()}
Unbinds given queue to the exchange