Lux.Signal.Router behaviour (Lux v0.5.0)
View SourceDefines the router behavior and provides a clean interface for signal routing.
The router is responsible for delivering signals between agents and managing subscriptions to signal events. It supports different implementations (e.g. Local, Remote) through a behavior pattern.
Usage
# Start a local router
{:ok, _pid} = Router.Local.start_link(name: :my_router)
# Route a signal
Router.route(signal, implementation: Router.Local, name: :my_router, hub: :my_hub)
# Subscribe to signal events
Router.subscribe(signal_id, implementation: Router.Local, name: :my_router)
Summary
Callbacks
Routes a signal through the router.
Subscribes to signal events.
Unsubscribes from signal events.
Functions
Routes a signal through the router.
Subscribes to signal events.
Unsubscribes from signal events.
Types
@type router() :: GenServer.server()
@type router_opts() :: keyword()
@type signal() :: Lux.Signal.t()
Callbacks
@callback route(signal(), router_opts()) :: :ok | {:error, term()}
Routes a signal through the router.
Options
:implementation
- The router implementation module (defaults to Local):name
- The registered name of the router process:hub
- The hub to use for routing (required)
@callback subscribe(String.t(), router_opts()) :: :ok | {:error, term()}
Subscribes to signal events.
Options
:implementation
- The router implementation module (defaults to Local):name
- The registered name of the router process
@callback unsubscribe(String.t(), router_opts()) :: :ok | {:error, term()}
Unsubscribes from signal events.
Options
:implementation
- The router implementation module (defaults to Local):name
- The registered name of the router process
Functions
Routes a signal through the router.
Options
:implementation
- The router implementation module (defaults to Local):name
- The registered name of the router process:hub
- The hub to use for routing (required)
Subscribes to signal events.
Options
:implementation
- The router implementation module (defaults to Local):name
- The registered name of the router process
Unsubscribes from signal events.
Options
:implementation
- The router implementation module (defaults to Local):name
- The registered name of the router process