Lux.Signal.Router behaviour (Lux v0.5.0)

View Source

Defines 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

router()

@type router() :: GenServer.server()

router_opts()

@type router_opts() :: keyword()

signal()

@type signal() :: Lux.Signal.t()

Callbacks

route(signal, router_opts)

@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)

subscribe(t, router_opts)

@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

unsubscribe(t, router_opts)

@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

route(signal, opts)

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)

subscribe(signal_id, opts)

Subscribes to signal events.

Options

  • :implementation - The router implementation module (defaults to Local)
  • :name - The registered name of the router process

unsubscribe(signal_id, opts)

Unsubscribes from signal events.

Options

  • :implementation - The router implementation module (defaults to Local)
  • :name - The registered name of the router process