Process-scoped Redis connections for concurrent tests.
Start a named sandbox with start_link/1, then check out that sandbox in each
test with checkout/1. Redis commands use the {:via, RedixSandbox, name} tuple to
resolve to the calling test's connection.
Summary
Functions
Allows a process to use the calling owner's checked-out Redis connection.
Checks out a Redis connection for the calling process.
Returns a specification to start this module under a supervisor.
Changes the ownership mode of a sandbox.
Starts a named sandbox.
Types
Functions
@spec allow(name(), pid(), pid()) :: :ok | {:error, RedixSandbox.Errors.AllowError.t()}
Allows a process to use the calling owner's checked-out Redis connection.
The owner must already have checked out the sandbox. The child shares the owner's logical Redis database.
@spec checkout(name()) :: :ok | {:error, RedixSandbox.Errors.CheckoutError.t()}
Checks out a Redis connection for the calling process.
The pool implementation will reserve a logical Redis DB, flush it, and record
the calling process as its owner before returning :ok. Failures return a
RedixSandbox.Errors.CheckoutError with the sandbox, database when applicable, operation, and
original reason.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec mode(name(), mode()) :: :ok | {:error, RedixSandbox.Errors.ModeError.t()}
Changes the ownership mode of a sandbox.
In shared mode, the owner must already have checked out the sandbox and all callers
resolve that owner's Redis connection. Use :private to restore process isolation.
@spec start_link(keyword()) :: Supervisor.on_start()
Starts a named sandbox.
Each sandbox owns its Redix connections and NimbleOwnership server.
@spec unregister_name(name()) :: :ok