LemonCore.EventBridge (lemon_core v0.1.0)

View Source

Optional bridge for subscribing/unsubscribing external event fanout.

:lemon_router wants to request "subscribe this run_id" for WebSocket/event delivery, but should not depend on :lemon_control_plane at compile time.

This module performs dynamic dispatch to a configured implementation module. If no implementation is configured, calls are no-ops.

Summary

Functions

Configure the implementation module.

Configure the implementation module with overwrite controls.

Configure the bridge implementation only if no conflicting implementation is set.

Subscribe to events for the given run ID.

Unsubscribe from events for the given run ID.

Types

configure_mode()

@type configure_mode() :: :replace | :if_unset

Functions

configure(mod)

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

Configure the implementation module.

Typically called by LemonControlPlane.Application at startup:

LemonCore.EventBridge.configure(LemonControlPlane.EventBridge)

configure(mod, opts)

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

Configure the implementation module with overwrite controls.

Modes:

  • :replace - overwrite any existing implementation (legacy behavior)
  • :if_unset - set only when unset or already matching

configure_guarded(mod)

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

Configure the bridge implementation only if no conflicting implementation is set.

subscribe_run(run_id)

@spec subscribe_run(binary()) :: :ok

Subscribe to events for the given run ID.

Dispatches to the configured implementation module. No-op if unconfigured.

unsubscribe_run(run_id)

@spec unsubscribe_run(binary()) :: :ok

Unsubscribe from events for the given run ID.

Dispatches to the configured implementation module. No-op if unconfigured.