Jido.Signal.Bus.State (Jido v1.1.0-rc.2)

View Source

Defines the state structure for the signal bus.

This module contains the type definitions and operations for managing the internal state of the signal bus, including signal logs, subscriptions, snapshots, and router configuration. It provides functions for manipulating and querying this state.

Summary

Functions

Merges a list of recorded signals into the existing log. Signals are added to the log keyed by their IDs. If a signal with the same ID already exists, it will be overwritten.

Clears all signals from the log.

Truncates the signal log to the specified maximum size. Keeps the most recent signals and discards older ones.

Types

t()

@type t() :: %Jido.Signal.Bus.State{
  child_supervisor: pid() | nil,
  log: %{required(String.t()) => Jido.Signal.t()},
  name: atom(),
  router: Jido.Signal.Router.Router.t(),
  snapshots: %{required(String.t()) => Jido.Signal.t()},
  subscriptions: %{required(String.t()) => Jido.Signal.Bus.Subscriber.t()}
}

Functions

add_route(state, route)

add_subscription(state, subscription_id, subscription)

append_signals(state, signals)

@spec append_signals(t(), [Jido.Signal.t() | {:ok, Jido.Signal.t()} | map()]) ::
  {:ok, t(), [Jido.Signal.t()]} | {:error, term()}

Merges a list of recorded signals into the existing log. Signals are added to the log keyed by their IDs. If a signal with the same ID already exists, it will be overwritten.

Parameters

  • state: The current bus state
  • signals: List of recorded signals to merge

Returns

  • with signals merged into log
  • if there was an error processing the signals

clear_log(state)

Clears all signals from the log.

dbug(_, _ \\ [])

(macro)

error(_, _ \\ [])

(macro)

get_subscription(state, subscription_id)

has_subscription?(state, subscription_id)

log_to_list(state)

remove_route(state, route)

remove_subscription(state, subscription_id, opts \\ [])

truncate_log(state, max_size)

Truncates the signal log to the specified maximum size. Keeps the most recent signals and discards older ones.