View Source Kiq.Pool (Kiq v0.7.3)

Kiq maintains a fixed pool of Redix connections that are used by processes to communicate with Redis.

The pool is a fixed set of supervised connections. Calling checkout/1 will return a random connection pid. The Redis connection is fully duplexed, making it safe for multiple processes to use the same connection simultaneously. Connections never need to be checked back in.

Ad-Hoc Usage

Each supervised Kiq instance will have its own pool. The pool name is derived from the module name, i.e. the module MyApp.Kiq would have a supervised pool registered as MyApp.Kiq.Pool. The name can be used to checkout connections and execute commands in the console.

For example, to get a list of the queues that are currently active:

MyApp.Kiq.Pool
|> Kiq.Pool.checkout()
|> Redix.command(["SMEMBERS", "queues"])

Summary

Functions

Get the pid of a supervised Redix connection.

Returns a specification to start this module under a supervisor.

Types

@type options() :: [config: Kiq.Config.t(), name: GenServer.name()]

Functions

Link to this function

checkout(server \\ __MODULE__)

View Source
@spec checkout(GenServer.server()) :: pid()

Get the pid of a supervised Redix connection.

Connections are randomly allocated and don't need to be checked back in.

Returns a specification to start this module under a supervisor.

See Supervisor.