AmqpSidecar.Broker behaviour (amqp_sidecar v0.1.0)

Copy Markdown

Behaviour abstracting the AMQP client.

The production implementation (AmqpSidecar.Broker.AMQP) talks to RabbitMQ. Tests inject AmqpSidecar.Broker.Mock (Mox) via Application.get_env(:amqp_sidecar, :broker).

Summary

Types

channel()

@type channel() :: term()

connection()

@type connection() :: term()

Callbacks

ack(channel, non_neg_integer)

@callback ack(channel(), non_neg_integer()) :: :ok | {:error, term()}

bind_queue(channel, t, t, keyword)

@callback bind_queue(channel(), String.t(), String.t(), keyword()) ::
  :ok | {:error, term()}

close_channel(channel)

@callback close_channel(channel()) :: :ok | {:error, term()}

close_connection(connection)

@callback close_connection(connection()) :: :ok | {:error, term()}

consume(channel, t)

@callback consume(channel(), String.t()) :: {:ok, String.t()} | {:error, term()}

declare_exchange(channel, t, t, keyword)

@callback declare_exchange(channel(), String.t(), String.t(), keyword()) ::
  :ok | {:error, term()}

declare_queue(channel, t, keyword)

@callback declare_queue(channel(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

open_channel(connection)

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

open_connection(t)

@callback open_connection(String.t()) :: {:ok, connection()} | {:error, term()}

publish(channel, t, t, t, keyword)

@callback publish(channel(), String.t(), String.t(), String.t(), keyword()) ::
  :ok | {:error, term()}

reject(channel, non_neg_integer, keyword)

@callback reject(channel(), non_neg_integer(), keyword()) :: :ok | {:error, term()}