Class ModelCommitWireCodec

java.lang.Object
io.fluxzero.common.api.modeling.ModelCommitWireCodec

public final class ModelCommitWireCodec extends Object
Compact websocket representation for the common one-event, one-target model commit.

The regular polymorphic JSON/CBOR representation remains authoritative and is used automatically for every commit shape this codec does not support. This format only removes repeated object descriptors from homogeneous transport batches; it does not combine logical commits or alter their individual request IDs, idempotency keys, results, or transaction boundaries.

  • Method Details

    • tryEncode

      public static byte[] tryEncode(JsonType value) throws IOException
      Encodes a supported homogeneous request or result batch, returning null when the ordinary transport codec should be used.
      Throws:
      IOException
    • tryDecode

      public static JsonType tryDecode(byte[] bytes) throws IOException
      Decodes a compact batch, returning null when the payload uses the ordinary transport representation.
      Throws:
      IOException
    • restoreResultContext

      public static RequestResult restoreResultContext(RequestResult candidate, CommitModels request)
      Completes a compact decoded result with identities owned by its correlated request. Other result representations are returned unchanged.
    • materializeTransportResult

      public static RequestResult materializeTransportResult(RequestResult candidate)
      Expands a Runtime-owned compact result for an ordinary JSON or CBOR transport, including when delivery moves to another session. Results already in ordinary form are unchanged. Decoded compact results must instead use restoreResultContext(RequestResult, CommitModels) because their identities are owned by the correlated request, not by the wire payload.
      Throws:
      IllegalStateException - if a compact result has no retained Runtime identities
    • compactAcceptedResult

      public static RequestResult compactAcceptedResult(long requestId, long stateIndex, Long eventIndex, long sequenceNumber, boolean historyComplete)
      Creates the compact transport form of an accepted single-target result without the durable commit and model identities owned by its correlated request. The SDK restores those identities before publication.
    • compactAcceptedResult

      public static RequestResult compactAcceptedResult(CommitModels request, long stateIndex, Long eventIndex, long sequenceNumber, boolean historyComplete)
      Creates a compact Runtime result retaining only the commit and model identity references needed for delivery through another transport. No request or payload is retained, and the identities are omitted from the compact wire representation.
    • requiresRequestContext

      public static boolean requiresRequestContext(RequestResult candidate)
      Returns whether a decoded transport result still needs its correlated request context.
    • isCompactResult

      public static boolean isCompactResult(RequestResult candidate)
      Returns whether a result can use the compact single-target wire representation.