EnvelopeCodec
Reads and writes Envelopes as the JSON value of a Kafka message, with Wow's mapper (WowJson): every number of a payload or a state keeps its exact value and scale, and the modules are fixed, so the wire form does not depend on what a host brings.
Value:
{"format":1,"kind":"state-event","id":…,"type":…,"payload":{…},"transport":{…}};transportis null when there is none, and holds thewaitcontext and thetraceonly, in the one form of a transport (me.ahoo.wow.spi.log.TransportCodec): the reservations of a log entry stay in the context.Reading: unknown fields are ignored at every level, so this version reads what the next minor one writes; a format other than Envelope.FORMAT, or a kind this version does not know, is refused with an IllegalArgumentException.
State events: stateEvent and stateEventOf turn a StateEventRecord into the envelope of kind EnvelopeKind.STATE_EVENT and back:
idisref@version,typethe aggregate type,payload{ref, version, commandId, requestId, commandType, commitTime, events, state, scope, deleted, access, accessVersion, causation, headers, operator, imported}(operator,imported,accessandaccessVersion, additions within format 1;importedonly when true;accessin its stored form, AccessValues, or null when not stamped, and an envelope of a version that wrotetagsinstead reads with none;accessVersionthe version it is of, null with it or when an envelope of an earlier version left it out) with each event{name, revision, payload}and the state{version, schemaFingerprint, state}or null.
Functions
Whether the message value value is an envelope at all, of any format or kind: a JSON object with an integer format and a text kind. A value that is not was written by another producer, such as a 9.x service on a topic of the same name, and no Wow version reads it; an envelope of another format or kind is one a later version may.
The message of record: keyed by its aggregate ref, its value the bytes of stateEvent's envelope, written from the record at once rather than through the envelope's JSON tree.
The envelope of record.