Freddy.Adapter behaviour (freddy v0.17.1)
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
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()
Specs
channel() :: pid()
connection()
Specs
connection() :: pid()
consumer_tag()
Specs
consumer_tag() :: String.t()
delivery_tag()
Specs
delivery_tag() :: String.t()
error()
Specs
error() :: atom()
exchange_name()
Specs
exchange_name() :: String.t()
exchange_type()
Specs
meta()
Specs
meta() :: map()
options()
Specs
options() :: Keyword.t()
payload()
Specs
payload() :: String.t()
queue_name()
Specs
queue_name() :: String.t()
queue_opts()
Specs
queue_opts() :: Keyword.t()
routing_key()
Specs
routing_key() :: String.t()
Link to this section Callbacks
ack(channel, delivery_tag, options)
Specs
ack(channel(), delivery_tag(), options()) :: :ok | {:error, error()}
Acks a message
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
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
close_channel(channel)
Specs
Closes existing channel
close_connection(connection)
Specs
close_connection(connection()) :: :ok | {:error, error()}
Closes AMQP connection
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
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
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
delete_queue(channel, queue_name, options)
Specs
delete_queue(channel(), queue_name(), options()) :: {:ok, meta()} | {:error, error()}
Deletes the given queue
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_connection(connection)
Specs
link_connection(connection()) :: :ok
Links current process to a connection
monitor_channel(channel)
Specs
Sets up a monitor on a channel
nack(channel, delivery_tag, options)
Specs
nack(channel(), delivery_tag(), options()) :: :ok | {:error, error()}
Nacks a message
open_channel(connection)
Specs
open_channel(connection()) :: {:ok, channel()} | {:error, error()}
Opens new channel on connection
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.
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
qos(channel, options)
Specs
Set up channel QoS
register_return_handler(channel, pid)
Specs
Registers given process as a return handler for the given channel
reject(channel, delivery_tag, options)
Specs
reject(channel(), delivery_tag(), options()) :: :ok | {:error, error()}
Rejects a message
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