PayloadCodec

interface PayloadCodec

Payload codec.

This allows to transform journal payloads after they're serialized, before they're written to the wire, and before they're deserialized after they're read from the wire. A typical use case is service side journal encryption.

Payloads that are passed through the codec:

  • Handlers input and success output
  • ctx.run success results
  • Call/send parameters and call success results
  • Awakeables, durable promises and signals success results
  • State values

Failures (e.g. terminal error messages), state keys, headers and other metadata are not passed through the codec.

The encoding/decoding doesn't need to be deterministic, see isEncodingDeterministic.

The codec can be configured in the endpoint with Endpoint.Builder#withPayloadCodec(PayloadCodec), and in the ingress client with Client.connect(String, SerdeFactory, PayloadCodec, RequestOptions).

Implementations of this class MUST be thread safe and asynchronous, as they might block the I/O thread.

NOTE: Using this class in a service requires the native state machine, available on JDK 23+.

Properties

Link copied to clipboard
Noop codec.

Functions

Link copied to clipboard
abstract fun decode(payload: Slice): CompletableFuture<Slice>
Decodes the given payload.
Link copied to clipboard
abstract fun encode(payload: Slice): CompletableFuture<Slice>
Encodes the given payload.
Link copied to clipboard
Whether encode is deterministic, that is, whether encoding the same payload twice always produces the same bytes.