Jido.Signal.Bus.MiddlewarePipeline (Jido Signal v1.0.0)
View SourceHandles execution of middleware chains for signal bus operations.
This module provides functions to execute middleware callbacks in sequence, allowing each middleware to transform signals or control the flow of execution.
Summary
Functions
Executes the after_dispatch middleware chain.
Executes the after_publish middleware chain.
Executes the before_dispatch middleware chain for a single signal and subscriber.
Executes the before_publish middleware chain.
Initializes a list of middleware modules with their options.
Types
@type context() :: Jido.Signal.Bus.Middleware.context()
Functions
@spec after_dispatch( [middleware_config()], Jido.Signal.t(), Jido.Signal.Bus.Subscriber.t(), Jido.Signal.Bus.Middleware.dispatch_result(), context() ) :: :ok
Executes the after_dispatch middleware chain.
This is called for side effects only after a signal has been dispatched.
@spec after_publish([middleware_config()], [Jido.Signal.t()], context()) :: :ok
Executes the after_publish middleware chain.
This is called for side effects only - signals cannot be modified.
@spec before_dispatch( [middleware_config()], Jido.Signal.t(), Jido.Signal.Bus.Subscriber.t(), context() ) :: {:ok, Jido.Signal.t()} | :skip | {:error, term()}
Executes the before_dispatch middleware chain for a single signal and subscriber.
Returns the potentially modified signal, or indicates if dispatch should be skipped/halted.
@spec before_publish([middleware_config()], [Jido.Signal.t()], context()) :: {:ok, [Jido.Signal.t()]} | {:error, term()}
Executes the before_publish middleware chain.
Stops execution if any middleware returns :halt.
@spec init_middleware([{module(), keyword()}]) :: {:ok, [middleware_config()]} | {:error, term()}
Initializes a list of middleware modules with their options.
Returns a list of {module, state} tuples that can be used in the pipeline.