Jido.Signal.Bus.Partition (Jido Signal v2.2.2)

View Source

A partition handles a subset of subscriptions and their dispatch.

Partitions are used to distribute the load of signal dispatch across multiple processes. Each partition manages its own set of subscriptions based on a hash of the subscription ID.

Summary

Functions

Returns a specification to start this module under a supervisor.

Determines which partition a subscription should be routed to.

Returns the Zoi schema for Partition

Starts a partition worker linked to the calling process.

Returns a via tuple for looking up a partition by bus name and partition ID.

Types

t()

@type t() :: %Jido.Signal.Bus.Partition{
  burst_size: nil | integer(),
  bus_name: atom(),
  bus_pid: any(),
  journal_adapter: nil | nil | atom(),
  journal_pid: nil | nil | any(),
  last_refill: nil | nil | integer(),
  middleware: nil | [any()],
  middleware_timeout_ms: nil | integer(),
  partition_id: integer(),
  rate_limit_per_sec: nil | integer(),
  subscriptions: nil | map(),
  task_supervisor: nil | nil | any(),
  tokens: nil | float()
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

partition_for(subscription_id, partition_count)

@spec partition_for(String.t(), pos_integer()) :: non_neg_integer()

Determines which partition a subscription should be routed to.

schema()

Returns the Zoi schema for Partition

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Starts a partition worker linked to the calling process.

Options

  • :partition_id - The partition number (required)
  • :bus_name - The name of the parent bus (required)
  • :bus_pid - The PID of the parent bus (required)
  • :middleware - Middleware configurations (optional)
  • :middleware_timeout_ms - Timeout for middleware execution (default: 100)
  • :journal_adapter - Journal adapter module (optional)
  • :journal_pid - Journal adapter PID (optional)

via_tuple(bus_name, partition_id, opts \\ [])

@spec via_tuple(atom(), non_neg_integer(), keyword()) ::
  {:via, Registry, {module(), tuple()}}

Returns a via tuple for looking up a partition by bus name and partition ID.