Jido.Bus.Adapters.PubSub (Jido v1.1.0-rc)
View SourceA Jido Bus adapter implementation using Phoenix.PubSub for simple pub/sub messaging.
This adapter provides basic publish/subscribe functionality without persistence or replay capabilities. It is suitable for scenarios where you need lightweight message distribution without message history.
Features
- Simple publish/subscribe messaging using Phoenix.PubSub
- Support for stream-based subscriptions
- Auto-cleanup of subscriptions when subscribers terminate
- No message persistence or replay capabilities
Configuration
The adapter requires a Phoenix.PubSub server to be started. This is handled automatically
when starting the adapter through child_spec/2
.
Usage
# Start the bus with the PubSub adapter
{:ok, children, bus} = Jido.Bus.Adapters.PubSub.child_spec(MyApp, [])
Supervisor.start_link(children, strategy: :one_for_one)
# Subscribe to a stream
:ok = Jido.Bus.subscribe(bus, "my-stream")
# Publish signals
:ok = Jido.Bus.publish(bus, "my-stream", :any_version, [signal], [])
# Receive signals
receive do
{:signal, signal} -> handle_signal(signal)
end
Limitations
This adapter does not support:
- Message persistence
- Stream replay
- Persistent subscriptions
- Snapshots
- Message acknowledgments
Summary
Functions
Not implemented - this adapter does not support message acknowledgments.
Returns the child specification for starting the PubSub adapter.
Not implemented - this adapter does not support snapshots.
Publishes signals to a stream.
Not implemented - this adapter does not support snapshots.
Not implemented - this adapter does not support snapshots.
Not implemented - this adapter does not support stream replay.
Subscribes the current process to a stream.
Not implemented - this adapter does not support persistent subscriptions.
Unsubscribes from a stream or subscription.
Not implemented - this adapter does not support snapshots.
Functions
Not implemented - this adapter does not support message acknowledgments.
Returns the child specification for starting the PubSub adapter.
Options
:name
- The name to use for the PubSub server. Defaults to the provided context.
Returns
{:ok, children, bus}
- A tuple containing the child specs to start and the configured bus.
Not implemented - this adapter does not support snapshots.
Publishes signals to a stream.
The expected_version parameter is ignored as this adapter does not maintain stream versions.
Not implemented - this adapter does not support snapshots.
Not implemented - this adapter does not support snapshots.
Not implemented - this adapter does not support stream replay.
Subscribes the current process to a stream.
Not implemented - this adapter does not support persistent subscriptions.
Unsubscribes from a stream or subscription.
When given a PID, returns :ok since PubSub handles cleanup automatically. When given a stream_id, unsubscribes the current process from that stream.
Not implemented - this adapter does not support snapshots.