itk_queue v0.10.5 ITKQueue.ConnectionPool View Source

Manages a pool of connections to AMQP.

When a connection is needed call with_connection/1 and pass it the function that needs the connection. The function will be executed with a connection checked out from the pool. After the function completes the connection will be checked back into the pool.

Link to this section Summary

Functions

Return a connection to the pool

Retrieves a connection from the pool

Returns a specification to start this module under a supervisor

Provides a new channel from a connection from the connection pool

Provides a connection from the connection pool to perform an action

Link to this section Functions

Return a connection to the pool.

Retrieves a connection from the pool.

You are responsible for returning this connection to the pool when you are done with it.

Example: {ref, connection} = ITKQueue.ConnectionPool.checkout # … do something with the connection ITKQueue.ConnectionPool.checkin(ref)

Returns a specification to start this module under a supervisor.

See Supervisor.

Provides a new channel from a connection from the connection pool.

This channel will be closed and connection will automatically be returned to the pool when the action is complete.

Example: ITKQueue.ConnectionPool.with_channel(fn(channel) ->

# ... do something with the channel

end)

Provides a connection from the connection pool to perform an action.

This connection will automatically be returned to the pool when the action is complete.

Example: ITKQueue.ConnectionPool.with_connection(fn(connection) ->

# ... do something with the connection

end)