channels v0.0.1 Channels.Adapter behaviour

This module specifies the adapter API that an AMQP adapter is required to implement.

Summary

Callbacks

Ack a message

Bind a queue to an exchange

Close a channel

Starts an AMQP connection with the given config

Subscribe the given pid to a queue and receive messages

Closes an AMQP connection with the given config

Transform the given message to the expected format

Monitors the given AMQP connection

Nack a message

Start a channel on the given connection

Reject a message

Types

chan :: term
conn :: term
exchange :: binary
meta :: %{}
payload :: binary
queue :: binary
routing_key :: binary
t :: module
type :: :direct | :topic | :fanout

Callbacks

ack(chan, meta, opts)

Specs

ack(chan, meta, opts) :: :ok

Ack a message

bind(chan, queue, exchange, opts)

Specs

bind(chan, queue, exchange, opts) :: :ok

Bind a queue to an exchange

close_channel(chan)

Specs

close_channel(chan) :: :ok

Close a channel

connect(config)

Specs

connect(config) ::
  {:ok, conn} |
  {:error, reason :: term}

Starts an AMQP connection with the given config

consume(chan, queue, pid, opts)

Specs

consume(chan, queue, pid, opts) :: {:ok, consumer_tag :: binary}

Subscribe the given pid to a queue and receive messages

declare_exchange(chan, exchange, type, opts)

Specs

declare_exchange(chan, exchange, type, opts) ::
  :ok |
  {:error, reason :: term}

Declares an exchange

declare_queue(chan, queue, opts)

Specs

declare_queue(chan, queue, opts) ::
  {:ok, queue_info :: term} |
  {:error, reason :: term}

Declares a queue

disconnect(conn)

Specs

disconnect(conn) :: :ok

Closes an AMQP connection with the given config

handle(message)

Specs

handle(message :: term) ::
  {:ready, meta} |
  {:deliver, payload, meta} |
  {:cancel, meta} |
  :unknown

Transform the given message to the expected format

monitor(conn)

Specs

monitor(conn) :: reference

Monitors the given AMQP connection

nack(chan, meta, opts)

Specs

nack(chan, meta, opts) :: :ok

Nack a message

open_channel(conn)

Specs

open_channel(conn) ::
  {:ok, chan} |
  {:error, reason :: term}

Start a channel on the given connection

publish(chan, exchange, payload, routing_key, opts)

Specs

publish(chan, exchange, payload, routing_key, opts) :: :ok

Publish a message

reject(chan, meta, opts)

Specs

reject(chan, meta, opts) :: :ok

Reject a message