Class ModelCommitWireCodec
java.lang.Object
io.fluxzero.common.api.modeling.ModelCommitWireCodec
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 Summary
Modifier and TypeMethodDescriptionstatic RequestResultcompactAcceptedResult(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.static RequestResultcompactAcceptedResult(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.static booleanisCompactResult(RequestResult candidate) Returns whether a result can use the compact single-target wire representation.static RequestResultmaterializeTransportResult(RequestResult candidate) Expands a Runtime-owned compact result for an ordinary JSON or CBOR transport, including when delivery moves to another session.static booleanrequiresRequestContext(RequestResult candidate) Returns whether a decoded transport result still needs its correlated request context.static RequestResultrestoreResultContext(RequestResult candidate, CommitModels request) Completes a compact decoded result with identities owned by its correlated request.static JsonTypetryDecode(byte[] bytes) Decodes a compact batch, returningnullwhen the payload uses the ordinary transport representation.static byte[]Encodes a supported homogeneous request or result batch, returningnullwhen the ordinary transport codec should be used.
-
Method Details
-
tryEncode
Encodes a supported homogeneous request or result batch, returningnullwhen the ordinary transport codec should be used.- Throws:
IOException
-
tryDecode
Decodes a compact batch, returningnullwhen the payload uses the ordinary transport representation.- Throws:
IOException
-
restoreResultContext
Completes a compact decoded result with identities owned by its correlated request. Other result representations are returned unchanged. -
materializeTransportResult
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 userestoreResultContext(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
Returns whether a decoded transport result still needs its correlated request context. -
isCompactResult
Returns whether a result can use the compact single-target wire representation.
-