itk_queue v0.9.4 ITKQueue.ConnectionPool

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.

Summary

Functions

Return a connection to the pool

Retrieves a connection from the pool

Provides a new channel from a connection from the connection pool

Provides a connection from the connection pool to perform an action

Functions

checkin(pid)

Return a connection to the pool.

checkout()

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)

max_overflow()
with_channel(action)

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)

with_connection(action)

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)