Class Envelope

java.lang.Object
ru.pathcreator.pyc.rpc.core.envelope.Envelope

public final class Envelope extends Object
Фиксированный транспортный заголовок RPC-протокола.

Envelope — это 24-байтный little-endian заголовок, который записывается перед каждой пользовательской полезной нагрузкой. Он принадлежит транспортному протоколу и не зависит от пользовательского codec layer.

Envelope is a fixed 24-byte little-endian header written before every user payload. It belongs to the transport protocol and is independent of the user message codec layer.

Структура заголовка / Envelope layout:

offset   size   field           description
0        2      magic           fixed RPC signature, 0xAE01
2        2      version         envelope format version
4        4      messageTypeId   routing message type
8        8      correlationId   transport-level correlation id
16       4      flags           bit 0: request, bit 1: heartbeat, bit 2: error
20       4      payloadLength   payload size after the envelope, in bytes

Размер envelope намеренно равен 24 байтам. / The envelope length is intentionally 24 bytes:

  • размер кратен 8 и сохраняет естественное выравнивание полей / the size is divisible by 8 and keeps the fields naturally aligned;
  • MAGIC and VERSION помогают выявлять чужие, поврежденные или устаревшие кадры / help diagnose foreign, corrupted, or outdated frames;
  • OFFSET_PAYLOAD_LEN хранит длину payload явно, что удобно для валидации и вложенных форматов / stores the payload length explicitly, which helps with validation and nested formats.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Флаг, помечающий envelope как structured remote error response.
    static final int
    Флаг, помечающий envelope как heartbeat frame.
    static final int
    Флаг, помечающий envelope как RPC-запрос.
    static final int
    Размер заголовка envelope в байтах.
    static final short
    Фиксированная сигнатура протокола в начале каждого envelope.
    static final int
    Смещение поля correlation id внутри envelope, в байтах.
    static final int
    Смещение поля флагов внутри envelope, в байтах.
    static final int
    Смещение поля MAGIC внутри envelope, в байтах.
    static final int
    Смещение поля идентификатора типа сообщения внутри envelope, в байтах.
    static final int
    Смещение поля длины payload внутри envelope, в байтах.
    static final int
    Смещение поля VERSION внутри envelope, в байтах.
    static final int
    Зарезервированный тип сообщения для heartbeat frame-ов.
    static final int
    Зарезервированный тип сообщения для optional protocol handshake frame-ов.
    static final short
    Текущая версия формата envelope.
  • Method Summary

    Methods inherited from class Object

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

    • LENGTH

      public static final int LENGTH
      Размер заголовка envelope в байтах.

      Size of the envelope header in bytes.

      See Also:
    • MAGIC

      public static final short MAGIC
      Фиксированная сигнатура протокола в начале каждого envelope.

      Fixed protocol signature written at the beginning of every envelope.

      See Also:
    • VERSION

      public static final short VERSION
      Текущая версия формата envelope.

      Current envelope format version.

      See Also:
    • OFFSET_MAGIC

      public static final int OFFSET_MAGIC
      Смещение поля MAGIC внутри envelope, в байтах.

      Byte offset of the MAGIC field inside the envelope.

      See Also:
    • OFFSET_VERSION

      public static final int OFFSET_VERSION
      Смещение поля VERSION внутри envelope, в байтах.

      Byte offset of the VERSION field inside the envelope.

      See Also:
    • OFFSET_MESSAGE_TYPE

      public static final int OFFSET_MESSAGE_TYPE
      Смещение поля идентификатора типа сообщения внутри envelope, в байтах.

      Byte offset of the message type identifier field inside the envelope.

      See Also:
    • OFFSET_CORRELATION_ID

      public static final int OFFSET_CORRELATION_ID
      Смещение поля correlation id внутри envelope, в байтах.

      Byte offset of the correlation identifier field inside the envelope.

      See Also:
    • OFFSET_FLAGS

      public static final int OFFSET_FLAGS
      Смещение поля флагов внутри envelope, в байтах.

      Byte offset of the flags field inside the envelope.

      See Also:
    • OFFSET_PAYLOAD_LEN

      public static final int OFFSET_PAYLOAD_LEN
      Смещение поля длины payload внутри envelope, в байтах.

      Byte offset of the payload length field inside the envelope.

      See Also:
    • FLAG_IS_REQUEST

      public static final int FLAG_IS_REQUEST
      Флаг, помечающий envelope как RPC-запрос.

      Flag bit that marks an envelope as an RPC request.

      See Also:
    • FLAG_IS_HEARTBEAT

      public static final int FLAG_IS_HEARTBEAT
      Флаг, помечающий envelope как heartbeat frame.

      Flag bit that marks an envelope as a heartbeat frame.

      See Also:
    • FLAG_IS_ERROR

      public static final int FLAG_IS_ERROR
      Флаг, помечающий envelope как structured remote error response.

      Error frames still use the normal response message type id and correlation id, but their payload is interpreted as a transport error body instead of a user response payload.

      See Also:
    • RESERVED_HEARTBEAT

      public static final int RESERVED_HEARTBEAT
      Зарезервированный тип сообщения для heartbeat frame-ов.

      Пользовательские message type id должны быть положительными и не должны использовать reserved values.

      Reserved message type identifier used for heartbeat frames. User-defined message type identifiers should be positive and must not use reserved values.

      See Also:
    • RESERVED_PROTOCOL_HANDSHAKE

      public static final int RESERVED_PROTOCOL_HANDSHAKE
      Зарезервированный тип сообщения для optional protocol handshake frame-ов.

      Reserved message type identifier used for optional protocol handshake frames.

      See Also: