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:

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

delivery_error()

@type delivery_error() :: :bus_not_found | term()

delivery_opts()

@type delivery_opts() :: [target: delivery_target(), jido: module() | nil]

delivery_target()

@type delivery_target() :: atom()

Functions

deliver(signal, opts)

@spec deliver(Jido.Signal.t(), delivery_opts()) :: :ok | {:error, delivery_error()}

Delivers a signal to the specified signal bus.

Parameters

  • signal - The signal to deliver
  • opts - Validated options from validate_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

validate_opts(opts)

@spec validate_opts(Keyword.t()) :: {:ok, Keyword.t()} | {:error, term()}

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