HareMq.Connection (hare_mq v1.3.0)
GenServer module for managing AMQP connection.
This module handles the lifecycle of the AMQP connection and provides functions for getting, closing, and monitoring the connection.
Summary
Functions
Returns a specification to start this module under a supervisor.
Close the current connection.
Get the current connection.
Callback implementation for GenServer.init/1
.
Functions
Link to this function
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
Link to this function
close_connection()
Close the current connection.
Returns:
{:ok, connection}
: If the connection is successfully closed.{:error, :not_connected}
: If the connection is not established.
Examples
case HareMq.Connection.close_connection() do
{:ok, conn} -> IO.inspect(conn)
{:error, :not_connected} -> IO.puts("Not connected!")
end
Link to this function
get_connection()
Get the current connection.
Returns:
{:ok, connection}
: If the connection is established.{:error, :not_connected}
: If the connection is not established.
Examples
case HareMq.Connection.get_connection() do
{:ok, conn} -> IO.inspect(conn)
{:error, :not_connected} -> IO.puts("Not connected!")
end
Link to this function
init(_)
Callback implementation for GenServer.init/1
.
Link to this function