TaskBunny v0.0.1-dev.6 TaskBunny.Connection

A GenServer to handle RabbitMQ connection. If it fails to connect to the host, it will retry every 5 seconds.

The module also provides funcitons to access RabbitMQ connections.

Summary

Functions

Gets a RabbitMQ connection for the given host. Returns nil when the connection is not available

Similar to get_connection/1 but raises an error when connection is not ready

Initialises GenServer. Send a request to establish a connection

Asks server to send the connection back asynchronously. Once connection has been established, it will send a message with {:connected, connection} to the given process

Starts a GenServer process linked to the cunnrent process

Types

state()
state() :: {atom, %AMQP.Connection{pid: term} | nil, [pid]}

Functions

get_connection(host \\ :default)
get_connection(atom) :: struct | nil

Gets a RabbitMQ connection for the given host. Returns nil when the connection is not available.

get_connection!(host \\ :default)
get_connection!(atom) :: struct

Similar to get_connection/1 but raises an error when connection is not ready.

init(args)
init(tuple) :: {:ok, any}

Initialises GenServer. Send a request to establish a connection.

monitor_connection(host \\ :default, listener_pid)
monitor_connection(atom, pid) :: :ok | :error

Asks server to send the connection back asynchronously. Once connection has been established, it will send a message with {:connected, connection} to the given process.

Returns :ok when the server exists. Returns :error when the server doesn’t exist.

start_link(host)
start_link(atom | state) :: GenServer.on_start

Starts a GenServer process linked to the cunnrent process.