hare v0.2.2 Hare.Core.Conn.State.Bridge
This module defines the Conn.State.Bridge
struct that keeps
the state and configuration of the AMQP connection, and the main
functions for working with it.
Bridge fields
Adapter fields:
adapter
- the adapter to the underlying AMQP libraryconfig
- the configuration to be given to the adapter when opening connection
Retrying failed connection fields:
backoff
- a list of time intervals (in ms) to wait to retry a failed connectionnext_intervals
- the list of remaining backoff intervals for the current retrying process
Information regarding the current active connection:
given
- the term given by the AMQP adapter representing a connectionref
- the monitoring reference for the connectionstatus
- the current connection status (:not_connected | :connected | :reconnecting)
Backoff and failed connections
When the connect/1 function is called and the AMQP adapter fails to establish connection
the status is set to :reconnecting and it {:retry, backoff_interval, reason, new_state}
.
When connect/1 is called again and it fails again the same response is given with the next
backoff interval.
When all but one backoff intervals have been returned, the last one is returned forever.
Summary
Functions
Establishes connection through the AMQP adapter
Disconnects the current connection
Returns the current AMQP adapter connection term
Creates a new Bridge struct
Opens a new channel on the active connection
Types
config_option :: {:adapter, adapter} | {:backoff, backoff} | {:config, adapter_config}
Functions
Establishes connection through the AMQP adapter.
On success it returns {:ok, bridge}
.
On failure it returns {:retry, interval, reason, bridge}
and expects
the caller to wait that interval before calling connect/1
again.
Disconnects the current connection.
If connected it disconnects, otherwise it does nothing.
Returns the current AMQP adapter connection term.
Creates a new Bridge struct.
It expect the given config to contain the following fields:
:adapter
- the AMQP adapter to use:backoff
- the list of backoff intervals:config
- the AMQP adapter config to use when establishing connection
open_channel(t) :: {:ok, Hare.Adapter.chan} | {:error, reason :: term} | :not_connected
Opens a new channel on the active connection.
When the status is :connected, it returns the adapter’s open_channel/1
result, otherwise it returns :not_connected
.