Skip to content

Platform payloads and command payloads

Every payload between Virtufin components is schema'd protobuf, owned by its contract's owner (openspec pubsub-topics, Platform Event Payloads). The only exception is a venue's own frame on feed.message and account.update.

Errors and metrics

The worker bases publish two payloads, each with one content type for every worker type. The ce-type and topic name the worker.

Topic Message Content type Fields
wrk.<type>.error virtufin.worker.WorkerError application/x-virtufin-worker-error+protobuf command, message
wrk.<type>.metrics virtufin.worker.WorkerMetrics application/x-virtufin-worker-metrics+protobuf worker_id, counters (name to int64), at
  • C#: WorkerEvents (Encode, Decode<T>, Schemas; records WorkerErrorPayload, WorkerMetricsPayload).
  • Python: virtufin.worker_devkit.worker_events (ERROR, METRICS, SCHEMAS).
  • TypeScript: WORKER_ERROR, WORKER_METRICS, WORKER_EVENT_SCHEMAS.

Command payloads

Each command a worker type takes has an input message and an answer message, owned by that worker type (openspec worker-management, Command Payloads):

  • input: application/x-virtufin-<type>-<command>-command+protobuf;
  • answer: application/x-virtufin-<type>-<command>-answer+protobuf.

A command without parameters has an empty input message. Register the worker type's commands once, list their schemas in the worker's payload schemas (they are registered when it starts), read an input and encode an answer:

static readonly CommandPayloads Commands = new CommandPayloads("eventstore")
    .Add<StatusCommand, StatusAnswer>("status");

protected override IReadOnlyList<PayloadSchema> PayloadSchemas => Commands.Schemas;

var input = Commands.Input<StatusCommand>(command);   // the command event
var answer = Commands.Answer(new StatusAnswer { Events = 3 });   // data, content type, dataschema

Python: CommandPayloads("hello").add("greet", GreetCommand, GreetAnswer), then input(command, data) and answer(command, message). TypeScript: new CommandPayloads("hello").add("greet", GreetCommandSchema, GreetAnswerSchema).

A failed command answers with WorkerError on wrk.<type>.error, never with an answer message.