Jido.Signal.Bus (Jido v1.1.0-rc.2)
View SourceImplements a signal bus for routing, filtering, and distributing signals.
The Bus acts as a central hub for signals in the system, allowing components to publish and subscribe to signals. It handles routing based on signal paths, subscription management, persistence, and signal filtering. The Bus maintains an internal log of signals and provides mechanisms for retrieving historical signals and snapshots.
Summary
Functions
Acknowledges a signal for a persistent subscription.
Returns a child specification for starting the bus under a supervisor.
Starts a new bus process. Options
Publishes a list of signals to the bus. Returns {:ok, recorded_signals} on success.
Reconnects a client to a persistent subscription.
Replays signals from the bus log that match the given path pattern. Optional start_timestamp to replay from a specific point in time.
Creates a new snapshot of signals matching the given path pattern.
Deletes a snapshot by its ID.
Lists all available snapshots.
Reads a snapshot by its ID.
Subscribes to signals matching the given path pattern. Options
Unsubscribes from signals using the subscription ID. Options
Types
Functions
@spec ack(server(), subscription_id(), String.t() | integer()) :: :ok | {:error, term()}
Acknowledges a signal for a persistent subscription.
@spec child_spec(keyword()) :: Supervisor.child_spec()
Returns a child specification for starting the bus under a supervisor.
Options
- name: The name to register the bus under (required)
- router: A custom router implementation (optional)
Starts a new bus process. Options:
- name: The name to register the bus under (required)
- router: A custom router implementation (optional)
@spec publish(server(), [Jido.Signal.t()]) :: {:ok, [Jido.Signal.Bus.RecordedSignal.t()]} | {:error, term()}
Publishes a list of signals to the bus. Returns {:ok, recorded_signals} on success.
@spec reconnect(server(), subscription_id(), pid()) :: {:ok, non_neg_integer()} | {:error, term()}
Reconnects a client to a persistent subscription.
@spec replay(server(), path(), non_neg_integer(), Keyword.t()) :: {:ok, [Jido.Signal.Bus.RecordedSignal.t()]} | {:error, term()}
Replays signals from the bus log that match the given path pattern. Optional start_timestamp to replay from a specific point in time.
@spec snapshot_create(server(), path()) :: {:ok, Jido.Signal.Bus.Snapshot.SnapshotRef.t()} | {:error, term()}
Creates a new snapshot of signals matching the given path pattern.
Deletes a snapshot by its ID.
@spec snapshot_list(server()) :: [Jido.Signal.Bus.Snapshot.SnapshotRef.t()]
Lists all available snapshots.
@spec snapshot_read(server(), String.t()) :: {:ok, Jido.Signal.Bus.Snapshot.SnapshotData.t()} | {:error, term()}
Reads a snapshot by its ID.
@spec subscribe(server(), path(), Keyword.t()) :: {:ok, subscription_id()} | {:error, term()}
Subscribes to signals matching the given path pattern. Options:
- dispatch: How to dispatch signals to the subscriber (default: async to calling process)
- persistent: Whether the subscription should persist across restarts (default: false)
@spec unsubscribe(server(), subscription_id(), Keyword.t()) :: :ok | {:error, term()}
Unsubscribes from signals using the subscription ID. Options:
- delete_persistence: Whether to delete persistent subscription data (default: false)
See Jido.Util.whereis/2
.