Skip to content

Base classes

WorkerBase<,> is the typed worker the WorkManager host calls through IWorker. It decodes the input payload with an ICloudEventCodec<,>, builds the response envelope, and supports multi-output workers.

public sealed class MyWorker() : WorkerBase<JsonNode, JsonObject>(
    new Uri("urn:virtufin:worker:my"), "my.response",
    myProcess.FromCloudEvents(Decode).ToCloudEvents(Encode))
{
    protected override JsonNode Decode(CloudEvent input) => JsonNode.Parse((string)input.Data!)!;
    protected override Outgoing Encode(JsonNode input, JsonObject value) => …;
}
Base Use when
WorkerBase<TInput, TOutput> one input payload, zero or more outputs
CommandWorker<T> the worker dispatches commands carried by the input
ApiWorker the worker exposes a gRPC API through the host

WorkerBase also carries the envelope helpers (EnvelopeAttributes, CloudEventExtensions) and WorkerTypeNames; see Envelope.

These types moved here from Virtufin.Worker.Host in 0.25.0. The host keeps IWorker, WorkerContext, IGatewayClient and the native/AOT protocol.