Interface ICloudEventCodec<TInput, TOutput>
- Namespace
- Virtufin.Worker.DevKit
- Assembly
- Virtufin.Worker.DevKit.dll
Pluggable codec for decoding a CloudEvent's Data payload into a worker-typed input and encoding a worker-typed output back into data + content-type for the response CloudEvent. Concrete implementations: JsonCloudEventCodec (default), and (future) Protobuf/flat-buffer/binary codecs.
public interface ICloudEventCodec<TInput, TOutput>
Type Parameters
TInputWorker-typed input representation. The codec maps from Data to
TInputvia DecodePayload(CloudEvent).TOutputWorker-typed output representation. The codec maps from
TOutputto a (data, contentType) tuple via EncodeResponse(TOutput) / EncodeError(string).
Methods
DecodePayload(CloudEvent)
Decode the CloudEvent's Data payload into the worker's typed input representation. Implementations may read DataContentType to decide the parser.
TInput DecodePayload(CloudEvent input)
Parameters
inputCloudEvent
Returns
- TInput
EncodeError(string)
Encode an error message into a (data, contentType) tuple for
error responses. Default convention mirrors the response shape.
(object data, string contentType) EncodeError(string message)
Parameters
messagestring
Returns
EncodeResponse(TOutput)
Encode the worker's typed response into a
(data, contentType) tuple suitable for assignment to
Data and DataContentType.
(object data, string contentType) EncodeResponse(TOutput payload)
Parameters
payloadTOutput