Jido. Signal. Dispatch. Bus
(Jido Signal v2.2.0)
View Source
An adapter for dispatching signals through the Jido signal bus system.
This adapter implements the Jido.Signal.Dispatch.Adapter behaviour and provides
functionality to publish signals to named signal buses. It integrates with the
Jido.Signal.Bus system for signal distribution.
Configuration Options
:target- (required) The atom name of the target bus:jido- (optional) The instance module for instance-scoped bus lookup
Signal Bus Integration
The adapter uses Jido.Signal.Bus to:
- Locate the target bus process using
Jido.Signal.Bus.whereis/2 - Publish signals using
Jido.Signal.Bus.publish/2
Examples
# Basic usage
config = {:bus, [
target: :my_bus
]}
# Instance-scoped bus lookup
config = {:bus, [
target: :my_bus,
jido: MyApp.Jido
]}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 signal bus.
Validates the bus adapter configuration options.
Types
@type delivery_error() :: :bus_not_found | term()
@type delivery_opts() :: [target: delivery_target(), jido: module() | nil]
@type delivery_target() :: atom()
Functions
@spec deliver(Jido.Signal.t(), delivery_opts()) :: :ok | {:error, delivery_error()}
Delivers a signal to the specified signal bus.
Parameters
signal- The signal to deliveropts- Validated options fromvalidate_opts/1
Options
:target- (required) The atom name of the target bus:jido- (optional) The instance module for scoped lookup
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:jido- Must be an atom representing the instance module, or nil
Returns
{:ok, validated_opts}- Options are valid{:error, reason}- Options are invalid with string reason