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":{…}}; transport is null when there is none, and holds the wait context and the trace only, 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: id is ref@version, type the aggregate type, payload {ref, version, commandId, requestId, commandType, commitTime, events, state, scope, deleted, access, accessVersion, causation, headers, operator, imported} (operator, imported, access and accessVersion, additions within format 1; imported only when true; access in its stored form, AccessValues, or null when not stamped, and an envelope of a version that wrote tags instead reads with none; accessVersion the 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

Link copied to clipboard

The envelope bytes hold.

Link copied to clipboard
fun encode(envelope: Envelope): ByteArray

envelope as the bytes of a message value.

Link copied to clipboard
fun headers(envelope: Envelope): Map<String, String>

The headers of a message holding envelope (EnvelopeHeaders).

Link copied to clipboard

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.

Link copied to clipboard

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.

fun message(key: String, envelope: Envelope): TopicMessage

The message of envelope under key: its value encoded, its headers.

Link copied to clipboard

The envelope of record.

Link copied to clipboard

The record the message value bytes hold.

The record envelope holds, with the envelope's transport.