LemonRouter.Router (lemon_router v0.1.0)

View Source

Main router for handling inbound messages and control plane requests.

The router is responsible for:

  • Normalizing inbound messages from different channels
  • Routing to the appropriate session
  • Handling abort requests
  • Applying pending compaction for all channels

Summary

Functions

Abort all runs for a session.

Abort a specific run by ID.

Handle a control plane agent request.

Handle an inbound message from a channel.

Apply a watchdog keepalive decision to a specific run.

Functions

abort(session_key, reason \\ :user_requested)

@spec abort(session_key :: binary(), reason :: term()) :: :ok

Abort all runs for a session.

abort_run(run_id, reason \\ :user_requested)

@spec abort_run(run_id :: binary(), reason :: term()) :: :ok

Abort a specific run by ID.

active_run(session_key)

@spec active_run(binary()) :: {:ok, binary()} | :none

handle_control_agent(params, ctx)

@spec handle_control_agent(params :: map(), ctx :: map()) ::
  {:ok, %{run_id: binary(), session_key: binary()}}
  | {:error, %{code: binary(), message: binary(), details: term()}}

Handle a control plane agent request.

Returns the run_id and session_key for tracking.

handle_inbound(msg)

@spec handle_inbound(LemonCore.InboundMessage.t()) :: :ok

Handle an inbound message from a channel.

Normalizes the message and submits it to the orchestrator. Before submission, applies any pending compaction marker for the session.

keep_run_alive(run_id, decision \\ :continue)

@spec keep_run_alive(run_id :: binary(), decision :: :continue | :cancel) :: :ok

Apply a watchdog keepalive decision to a specific run.

list_active_sessions()

@spec list_active_sessions() :: [%{session_key: binary(), run_id: binary()}]

session_busy?(session_key)

@spec session_busy?(binary()) :: boolean()