Lux.Signal.Router behaviour (Lux v0.3.0)
View SourceDefines the behaviour for signal routing between agents.
Routers are responsible for:
- Validating signals before delivery
- Finding appropriate target agents
- Delivering signals to target agents
- Supporting subscriptions to signal delivery events
Different implementations can handle routing in various ways:
- Local routing between agents in the same BEAM VM
- Remote routing to agents in different nodes
- External routing to agents in different systems/providers
Summary
Callbacks
Routes a signal to its target agent. Returns :ok if the signal was accepted for routing.
Starts a router process.
Subscribes to future signal delivery events. Subscribers will receive messages in the format: {:signal_delivered, signal_id} | {:signal_failed, signal_id, reason}
Unsubscribes from signal delivery events.
Types
Callbacks
@callback route(signal :: Lux.Signal.t(), opts :: routing_options()) :: :ok | {:error, term()}
Routes a signal to its target agent. Returns :ok if the signal was accepted for routing.
@callback start_link(opts :: keyword()) :: GenServer.on_start()
Starts a router process.
@callback subscribe(signal_id :: String.t(), opts :: routing_options()) :: :ok | {:error, term()}
Subscribes to future signal delivery events. Subscribers will receive messages in the format: {:signal_delivered, signal_id} | {:signal_failed, signal_id, reason}
@callback unsubscribe(signal_id :: String.t(), opts :: routing_options()) :: :ok | {:error, term()}
Unsubscribes from signal delivery events.