Roger.Partition (roger v3.0.0) View Source

Per-node partition registry

Roger implements multi-tenancy by dividing all its work between different "Partitions". Each partition is identified by a unique ID. Partitions consist of a list of queues, which are defined by its type (an atom) and a max_workers value which sets the concurrency level. The RabbitMQ queue name is constructed of the partition ID + the queue type.

To spread out the work, partitions can be started in the cluster on multiple nodes. The partition's queue configuration can be different between nodes - i.e. some node might be able to handle more concurrency than others.

Within the cluster, there is one global process (Roger.Partition.Global) which manages the partition's state. In it, it manages job's uniqueness, states of paused queues, et cetera.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Callback implementation for GenServer.init/1.

Reconfigure the given Roger partition

Stop the parition of accepting new jobs so it can finish of the remaining jobs

Start a Roger partition

Stop the given Roger partition

Link to this section Types

Specs

queue_def() :: {id :: String.t(), max_workers :: non_neg_integer()}

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Callback implementation for GenServer.init/1.

Specs

reconfigure(id :: String.t(), queues :: [queue_def()]) ::
  :ok | {:error, :not_running}

Reconfigure the given Roger partition

Use this function to adjust the queues for the partition. The queues argument is complete: any queues that are not mentioned, are stopped and messages in them will no longer be processed on this node.

Specs

safe_stop(id :: String.t()) :: :ok | {:error, :not_running}

Stop the parition of accepting new jobs so it can finish of the remaining jobs

Specs

start(id :: String.t(), queues :: [queue_def()]) :: {:ok, pid()}

Start a Roger partition

Given a unique ID and a list of queues, starts the partition supervision structure. When the partition has already been started, this calls reconfigure/2 instead.

Specs

stop(id :: String.t()) :: :ok | {:error, :not_running}

Stop the given Roger partition