Jido.Signal.Dispatch.Bus (Jido v1.1.0-rc)

View Source

An 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:

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

delivery_error()

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

delivery_opts()

@type delivery_opts() :: [target: delivery_target(), stream: String.t()]

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 event bus.

Parameters

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

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
  • :stream - Must be a string, defaults to "default"

Returns

  • {:ok, validated_opts} - Options are valid
  • {:error, reason} - Options are invalid with string reason