View Source WhiteRabbit.Connection (White Rabbit v0.2.0)
GenServer to open a %AMQP.Connection{}
and monitors it to allow for :stop
events and restarts from Supervisor.
Link to this section Summary
Types
## URL
Keyword list of conn_opt()
types. Provided to WhiteRabbit.Connection
struct.
%WhiteRabbit.Connection{} struct type, used for initial config and GenServer state.
Functions
Returns a specification to start this module under a supervisor.
Tries to start an %AMQP.Connection{}
with the passed config.
Link to this section Types
## URL
The AMQP 0-9-1 connection string like: "amqp:quest:quest@localhost:5672/dev"
See https://www.rabbitmq.com/uri-spec.html
## Options
:username
- The name of a user registered with the broker (default"guest"
):password
- The password of user (default to"guest"
):virtual_host
- The name of a virtual host in the broker (defaults"/"
):host
- The hostname of the broker (default"localhost"
):port
- The port the broker is listening on (default5672
):channel_max
- The channel_max handshake parameter (default0
):frame_max
- The frame_max handshake parameter (defaults0
):heartbeat
- The hearbeat interval in seconds (defaults10
):connection_timeout
- The connection timeout in milliseconds (efaults50000
):ssl_options
- Enable SSL by setting the location to cert files (default:none
):client_properties
- A list of extra client properties to be sent to the server (default[]
):socket_options
- Extra socket options. These are appended to the default options. See http://www.erlang.org/doc/man/inet.html#setopts-2 and http://www.erlang.org/doc/man/gen_tcp.html#connect-4 for descriptions of the available options:auth_mechanisms
- A list of authentication of SASL authentication mechanisms to use. See https://www.rabbitmq.com/access-control.html#mechanisms and https://github.com/rabbitmq/rabbitmq-auth-mechanism-ssl for descriptions of the available options:name
- A human-readable string that will be displayed in the management UI. Connection names do not have to be unique and cannot be used as connection identifiers (default:undefined
)
@type conn_opts() :: [conn_opt()]
Keyword list of conn_opt()
types. Provided to WhiteRabbit.Connection
struct.
Example
[conn_opts: [url: "amqp://user:pass@localhost:5673/dev"]]
@type t() :: %WhiteRabbit.Connection{ channels: [map()], conn_opts: keyword(), connection_name: atom() }
%WhiteRabbit.Connection{} struct type, used for initial config and GenServer state.
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec start_amqp_connection(t()) :: {:ok, {AMQP.Connection.t(), t()}} | {:ok, {nil, t()}}
Tries to start an %AMQP.Connection{}
with the passed config.
Monitors the opened connection so the Genserver can shut itself down in the event of an unexpected close. (Management API force-close, CLI close, etc.)
A {:ok, {, }} tuple is always returned so the Genserver will always start even if it cannot connect.