Kiq v0.6.0 Kiq.Pool View Source

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"])

Link to this section Summary

Functions

Get the pid of a supervised Redix connection

Returns a specification to start this module under a supervisor

Link to this section Types

Link to this type options() View Source
options() :: [config: Kiq.Config.t(), name: GenServer.name()]

Link to this section Functions

Link to this function checkout(server \\ __MODULE__) View Source
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.