Record Class ProtocolEnvelope
java.lang.Object
java.lang.Record
org.j7m.middleware.transport.api.ProtocolEnvelope
- Record Components:
protocolVersion- supported major protocol version (currently 1)requestId- stable idempotency/correlation keyschemaId- registered payload schema identifierschemaVersion- positive payload versiondeadline- absolute UTC execution deadlinetraceContext- bounded public trace metadata, containing no credentialscancellation- whether the request cancels the referenced operationnodeId- claimed sender bound to authenticated transport identity at dispatchpayload- encoded payload, limited to 1 MiB and defensively copied
public record ProtocolEnvelope(int protocolVersion, String requestId, String schemaId, int schemaVersion, Instant deadline, Map<String,String> traceContext, boolean cancellation, String nodeId, byte[] payload)
extends Record
Bounded transport-neutral command envelope. Authentication is supplied by the established transport,
never inferred from the claimed node identity. Immutable and safe to share across threads.
-
Constructor Summary
ConstructorsConstructorDescriptionProtocolEnvelope(int protocolVersion, String requestId, String schemaId, int schemaVersion, Instant deadline, Map<String, String> traceContext, boolean cancellation, String nodeId, byte[] payload) Snapshots mutable input and rejects unsupported protocol versions or size limits before dispatch. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of thecancellationrecord component.deadline()Returns the value of thedeadlinerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.nodeId()Returns the value of thenodeIdrecord component.byte[]payload()Returns an independent copy of the bounded encoded payload.intReturns the value of theprotocolVersionrecord component.Returns the value of therequestIdrecord component.schemaId()Returns the value of theschemaIdrecord component.intReturns the value of theschemaVersionrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thetraceContextrecord component.voidvalidateForDispatch(String authenticatedNode, Clock clock) Validates identity and deadline before invoking handlers or mutating state.
-
Constructor Details
-
ProtocolEnvelope
public ProtocolEnvelope(int protocolVersion, String requestId, String schemaId, int schemaVersion, Instant deadline, Map<String, String> traceContext, boolean cancellation, String nodeId, byte[] payload) Snapshots mutable input and rejects unsupported protocol versions or size limits before dispatch.- Throws:
IllegalArgumentException- if any identity, version or size is invalid
-
-
Method Details
-
payload
public byte[] payload()Returns an independent copy of the bounded encoded payload.- Returns:
- copied payload bytes
-
validateForDispatch
Validates identity and deadline before invoking handlers or mutating state.- Parameters:
authenticatedNode- trusted transport-authenticated peer identityclock- injected UTC clock- Throws:
MiddlewareException- if identity mismatches or deadline has expired
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
protocolVersion
public int protocolVersion()Returns the value of theprotocolVersionrecord component.- Returns:
- the value of the
protocolVersionrecord component
-
requestId
-
schemaId
-
schemaVersion
public int schemaVersion()Returns the value of theschemaVersionrecord component.- Returns:
- the value of the
schemaVersionrecord component
-
deadline
-
traceContext
Returns the value of thetraceContextrecord component.- Returns:
- the value of the
traceContextrecord component
-
cancellation
public boolean cancellation()Returns the value of thecancellationrecord component.- Returns:
- the value of the
cancellationrecord component
-
nodeId
-