Class PendingCallRegistry

java.lang.Object
ru.pathcreator.pyc.rpc.core.internal.PendingCallRegistry

public final class PendingCallRegistry extends Object
Реестр ожидающих RPC-вызовов по correlation id.

Класс хранит соответствие correlationId -> PendingCall и используется receive path-ом для поиска ожидающего вызова при приходе response frame-а.

Registry of pending RPC calls by correlation identifier. It stores correlationId -> PendingCall mappings and is used by the receive path to resolve incoming responses.

Внутри используются короткие критические секции под ReentrantLock, чтобы код оставался прозрачным и предсказуемым.

Internally the registry uses short ReentrantLock-guarded critical sections so the implementation stays explicit and predictable.

  • Constructor Summary

    Constructors
    Constructor
    Description
    PendingCallRegistry(int initialCapacity)
    Создает реестр ожидающих вызовов.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Применяет действие ко всем ожидающим вызовам и очищает реестр.
    void
    register(long correlationId, PendingCall call)
    Регистрирует ожидающий вызов по correlation id.
    remove(long correlationId)
    Удаляет и возвращает ожидающий вызов по correlation id.
    int
    Возвращает текущее количество ожидающих вызовов.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PendingCallRegistry

      public PendingCallRegistry(int initialCapacity)
      Создает реестр ожидающих вызовов.

      Creates a pending call registry.

      Parameters:
      initialCapacity - начальная емкость внутренней карты / initial capacity of the internal map
  • Method Details

    • register

      public void register(long correlationId, PendingCall call)
      Регистрирует ожидающий вызов по correlation id.

      Registers a pending call by correlation identifier.

      Parameters:
      correlationId - идентификатор корреляции / correlation identifier
      call - ожидающий вызов / pending call
    • remove

      public PendingCall remove(long correlationId)
      Удаляет и возвращает ожидающий вызов по correlation id.

      Removes and returns a pending call by correlation identifier.

      Parameters:
      correlationId - идентификатор корреляции / correlation identifier
      Returns:
      найденный pending call или null / matching pending call or null
    • forEachAndClear

      public void forEachAndClear(Consumer<PendingCall> action)
      Применяет действие ко всем ожидающим вызовам и очищает реестр.

      Метод обычно используется при переходе канала в down-state, чтобы завершить все ожидающие вызовы общей fail-fast причиной.

      Applies an action to all pending calls and clears the registry. The method is typically used when a channel enters a down-state and all waiting calls must fail fast for the same reason.

      Parameters:
      action - действие для каждого pending call / action to apply to each pending call
    • size

      public int size()
      Возвращает текущее количество ожидающих вызовов.

      Returns the current number of pending calls.

      Returns:
      размер реестра / registry size