Interface SessionTurnGate

All Known Implementing Classes:
LocalSessionTurnGate

public interface SessionTurnGate
Per-key mutual exclusion for gateway turns (user/channel inbound runs and subagent notification).

Implementations include LocalSessionTurnGate (process-local fair semaphore) and control-plane hosted locks for cross-node coordination. When using a distributed turn gate, ReActAgent conflictPolicy should be set to FAIL so concurrent state writes surface as errors rather than silent overwrites.

  • Method Summary

    Modifier and Type
    Method
    Description
    Acquires the turn slot for the given key, blocking until available or throwing when busy.
    boolean
    Non-blocking check: returns true when a turn is currently held for the given key.
  • Method Details

    • acquire

      Acquires the turn slot for the given key, blocking until available or throwing when busy.
      Parameters:
      key - canonical gate key (typically MsgContext.canonicalKey())
      Returns:
      a lease that must be closed to release the slot
      Throws:
      InterruptedException - if the waiting thread is interrupted
      TurnBusyException - if the slot is held and the implementation uses a short acquire timeout (distributed gates)
    • isRunning

      boolean isRunning(String key)
      Non-blocking check: returns true when a turn is currently held for the given key. Used by WakeupDispatcher to skip sessions that are already active.
      Parameters:
      key - canonical gate key
      Returns:
      true when a turn is in progress for the key