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

View Source

A GenServer that manages persistent subscription state and checkpoints for a single subscriber.

This module maintains the subscription state for a client, tracking which signals have been acknowledged and allowing clients to resume from their last checkpoint after disconnection. Each instance maps 1:1 to a bus subscriber and is managed as a child of the Bus's dynamic supervisor.

Summary

Functions

Returns a specification to start this module under a supervisor.

Returns the Zoi schema for PersistentSubscription

Starts a new persistent subscription process.

Types

t()

@type t() :: %Jido.Signal.Bus.PersistentSubscription{
  attempts: nil | map(),
  bus_pid: any(),
  bus_subscription: nil | nil | any(),
  checkpoint: nil | integer(),
  checkpoint_key: nil | nil | binary(),
  client_monitor_ref: nil | nil | any(),
  client_pid: any(),
  id: binary(),
  in_flight_signals: nil | map(),
  journal_adapter: nil | nil | atom(),
  journal_pid: nil | nil | any(),
  max_attempts: nil | integer(),
  max_in_flight: nil | integer(),
  max_pending: nil | integer(),
  pending_signals: nil | map(),
  retry_interval: nil | integer(),
  retry_timer_ref: nil | nil | any(),
  task_supervisor: nil | nil | any()
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

schema()

Returns the Zoi schema for PersistentSubscription

start_link(opts)

Starts a new persistent subscription process.

Options:

  • id: Unique identifier for this subscription (required)
  • bus_pid: PID of the bus this subscription belongs to (required)
  • path: Signal path pattern to subscribe to (required)
  • start_from: Where to start reading signals from (:origin, :current, or timestamp)
  • max_in_flight: Maximum number of unacknowledged signals (default: 1000)
  • max_pending: Maximum number of pending signals before backpressure (default: 10_000)
  • client_pid: PID of the client process (required)
  • dispatch_opts: Additional dispatch options for the subscription

via_tuple(id)

See Jido.Signal.Util.via_tuple/1.

whereis(id)

See Jido.Signal.Util.whereis/1.