Jido.Signal.Dispatch.Bus (Jido v1.1.0-rc)
View SourceAn adapter for dispatching signals through the Jido event bus system.
This adapter implements the Jido.Signal.Dispatch.Adapter
behaviour and provides
functionality to publish signals to named event buses. It integrates with the
Jido.Bus
system for event distribution.
Configuration Options
:target
- (required) The atom name of the target bus:stream
- (optional) The stream name to publish to, defaults to "default"
Event Bus Integration
The adapter uses Jido.Bus
to:
- Locate the target bus process using
Jido.Bus.whereis/1
- Publish signals to the specified stream using
Jido.Bus.publish/4
Examples
# Basic usage with default stream
config = {:bus, [
target: :my_bus
]}
# Specify custom stream
config = {:bus, [
target: :my_bus,
stream: "custom_events"
]}
Error Handling
The adapter handles these error conditions:
:bus_not_found
- The target bus is not registered- Other errors from the bus system
Summary
Functions
Delivers a signal to the specified event bus.
Validates the bus adapter configuration options.
Types
@type delivery_error() :: :bus_not_found | term()
@type delivery_opts() :: [target: delivery_target(), stream: String.t()]
@type delivery_target() :: atom()
Functions
@spec deliver(Jido.Signal.t(), delivery_opts()) :: :ok | {:error, delivery_error()}
Delivers a signal to the specified event bus.
Parameters
signal
- The signal to deliveropts
- Validated options fromvalidate_opts/1
Options
:target
- (required) The atom name of the target bus:stream
- (required) The stream name to publish to
Returns
:ok
- Signal published successfully{:error, :bus_not_found}
- Target bus not found{:error, reason}
- Other delivery failure
Validates the bus adapter configuration options.
Parameters
opts
- Keyword list of options to validate
Options
:target
- Must be an atom representing the bus name:stream
- Must be a string, defaults to "default"
Returns
{:ok, validated_opts}
- Options are valid{:error, reason}
- Options are invalid with string reason