Interface ScriptContextPublisher


public interface ScriptContextPublisher
Fire-and-forget publisher for the agent's script.context broker topic.

Scripts (and the runtime that hosts them) call into this interface to expose trace lines, lifecycle state changes, and freeform annotations to whoever is watching the topic — primarily NXTDebugger. Calls are non-blocking: the implementation enqueues onto a bounded ring and an internal worker thread forwards each entry as an _debug.publish RPC. Overflows drop the oldest entry rather than blocking the caller, mirroring the agent's per-pipe push queue.

When no debugger has subscribed, the agent's broker still accepts the publish and discards it — the per-method cost is one round-trip on the pipe, but the auto-tap fast-path keeps it off rpc.tap.

The NOOP instance is returned by ScriptContext.getScriptContext() when no channel is wired (tests, disconnected runtimes). Callers should never null-check the publisher; they always get a usable instance.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    No-op publisher.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    annotation(String key, Object value)
    Script-defined named annotation.
    void
    state(String state)
    Lifecycle state notification with no further detail.
    void
    state(String state, String detail)
    Lifecycle state notification with an optional human-readable detail.
    void
    trace(String level, String message)
    Free-form trace line.
  • Field Details

    • NOOP

      static final ScriptContextPublisher NOOP
      No-op publisher. Returned when no channel has been wired into the script context. All four methods are no-ops; never throws.
  • Method Details

    • state

      void state(String state)
      Lifecycle state notification with no further detail.
    • state

      void state(String state, String detail)
      Lifecycle state notification with an optional human-readable detail.
    • trace

      void trace(String level, String message)
      Free-form trace line. level is "INFO" / "WARN" / "ERROR" / "DEBUG".
    • annotation

      void annotation(String key, Object value)
      Script-defined named annotation. value may be any msgpack-encodable primitive (String, Number, Boolean) or nested Map / List; the wire codec serializes it verbatim into the push envelope so the debugger can render it without a per-key schema.