hare v0.2.2 Hare.Core.Conn
The Hare connection.
This module defines the connection process. It wraps the real AMQP connection and monitors it, handles failures and reconnections, and provides an interface to open new channels.
When the process has been started it tries to establish connection and, in case of failure, it keeps trying to reconnect forever.
When open_channel/1
is called and the connection is not established
it blocks the caller until the connection is established, after that it
opens a channel and returns it.
A timeout may be specified for this operation by using open_channel/2
.
By default the timeout is 5 seconds.
Summary
Functions
Returns the current AMQP connection given by the adapter
Opens a new channel on the current connection
Starts a Hare.Core.Conn
process linked to the current process
Closes the current AMQP connection if open, and stops the Hare.Core.Conn
process with the given reason (:normal
by default)
Types
Functions
Returns the current AMQP connection given by the adapter.
It is recommended to not use this function except for testing reasons.
open_channel(conn :: GenServer.server, timeout) :: {:ok, Hare.Core.Chan.t} | {:error, reason :: term}
Opens a new channel on the current connection.
If the connection is already established it opens a channel and returns it inmediately. Otherwise, when the connection has not been established yet or it failed and it is reconnecting, the client will block until the connection is established to open the channel and return it.
A timeout can be given to GenServer.call/3
.
Starts a Hare.Core.Conn
process linked to the current process.
It receives two arguments:
config
- The bridge configuration. SeeHare.Core.Conn.State.Bridge
for more informationopts
- GenServer options. SeeGenServer.start_link/3
for more information.
This function is used to start a Hare.Core.Conn
on a supervision tree, and
behaves like a GenServer.
Closes the current AMQP connection if open, and stops the Hare.Core.Conn
process with the given reason (:normal
by default).