LemonCore.EngineInfoBridge (lemon_core v0.1.0)

View Source

Optional bridge to the engine runtime, without compile-time coupling.

Channels and the control plane need three things that only the engine runtime (:lemon_gateway in the reference runtime) can answer: the resume syntax its custom engines accept, its transport registry for ops introspection, and any full-replacement gateway config it holds. Before this bridge each caller reached back with a hardcoded :"Elixir.LemonGateway.*" atom; now the engine runtime configures itself here at boot and callers ask core.

This is LemonCore.RouterBridge's pattern pointed the other way: a configured implementation module per capability, runtime dispatch, and a documented degraded answer when nothing is configured.

LemonCore.EngineInfoBridge.configure(
  engine_registry: LemonGateway.EngineRegistry,
  transport_registry: LemonGateway.TransportRegistry,
  gateway_config: LemonGateway.Config
)

Every function answers {:error, :unavailable} (or the documented empty value) when its capability is unconfigured, unloadable, or not running, so a runtime without an engine still serves channel messages and ops queries.

Summary

Functions

Whether a capability is configured, loadable, and (for registries) running.

Current bridge configuration.

Registers implementation modules. Unspecified capabilities are left alone.

Enabled transports as {id, module} pairs.

Extracts a resume token using the engine runtime's own resume syntax.

A full-replacement gateway config map, or :none.

The module implementing a transport id.

The module registered for capability, or nil.

Engine ids known to the engine runtime.

Transport ids the engine runtime has configured.

Whether the registry process behind capability is alive.

Types

capability()

@type capability() :: :engine_registry | :transport_registry | :gateway_config

config()

@type config() :: %{optional(capability()) => module()}

Functions

available?(capability)

@spec available?(capability()) :: boolean()

Whether a capability is configured, loadable, and (for registries) running.

config()

@spec config() :: config()

Current bridge configuration.

configure(opts)

@spec configure(keyword()) :: :ok | {:error, term()}

Registers implementation modules. Unspecified capabilities are left alone.

enabled_transports()

@spec enabled_transports() :: {:ok, [{term(), module()}]} | {:error, :unavailable}

Enabled transports as {id, module} pairs.

extract_resume(text)

@spec extract_resume(String.t()) :: {:ok, LemonCore.ResumeToken.t()} | :none

Extracts a resume token using the engine runtime's own resume syntax.

:none when no engine runtime is configured — callers fall back to the canonical LemonCore.ResumeToken syntax.

gateway_config()

@spec gateway_config() :: {:ok, map()} | :none

A full-replacement gateway config map, or :none.

The engine runtime may hold a config that replaces the canonical one wholesale (used by tests and by embedders that drive the gateway directly).

get_transport(id)

@spec get_transport(term()) :: {:ok, module()} | {:error, :unavailable}

The module implementing a transport id.

impl(capability)

@spec impl(capability()) :: module() | nil

The module registered for capability, or nil.

list_engines()

@spec list_engines() :: [String.t()]

Engine ids known to the engine runtime.

list_transports()

@spec list_transports() :: {:ok, [term()]} | {:error, :unavailable}

Transport ids the engine runtime has configured.

running?(capability)

@spec running?(capability()) :: boolean()

Whether the registry process behind capability is alive.