Table of Contents

Namespace Virtufin.Api.Client

Classes

ApiClient

Client for the Virtufin API Gateway: dynamic per-service RPC dispatch (service names as dynamic members, e.g. client.workmanager.SomeMethod()), plus direct methods for state, pub/sub, triggers and config.

ApiEndpoint

Configuration constants for the gateway's gRPC endpoint that other services call. The endpoint is configured via HostEnvVar and PortEnvVar, with defaults suitable for local development.

ApiError

A failure's ErrorInfo, read: its reason, and the field and resource it names.

ApiErrors

Building and reading the api's failures (openspec write-results): a non-OK status with a google.rpc.Status whose details hold an ErrorInfo, carried in the standard grpc-status-details-bin trailer (gRPC and gRPC-Web alike).

ApiEvents

The gateway's event payloads (openspec pubsub-topics, Platform Event Payloads): the content types and dataschemas of Virtufin.Api.Protos.StateChange, Virtufin.Api.Protos.TriggerScheduled, Virtufin.Api.Protos.TriggerDeleted and Virtufin.Api.Protos.TopicCatalogAdded.

ApiKeyClientInterceptor

Client-side gRPC interceptor that attaches x-api-key to every outbound call on the channel it is applied to. Pairs with the gateway's server-side ApiKeyInterceptor, which rejects every non-health-check call once at least one key is configured on it.

CloudEventFactory

Builds the protobuf CloudEvents that Pubsub.PublishEvent takes.

CloudEvents

CloudEvents v1.0 values this codebase writes.

ErrorReasons

The stable google.rpc.ErrorInfo reasons of the api's failures (openspec write-results), defined once here for the gateway, the WorkManager (which reuses this list and defines none of its own) and every C# caller. A failure is a non-OK gRPC status whose details hold one ErrorInfo with Domain, one of these reasons, and, where it applies, FieldKey and ResourceKey in its metadata. The list is documented in the api docs (reference, "Errors"); a reason, once published, keeps its meaning.

GatewayInvokeException

A backend failure the gateway reported in-band on Gateway.Invoke: the gRPC call itself succeeded, the response carried success = false with the backend's status code name, message and status details.

Ids

The one id generator (openspec item-identity, One Id Generator per Language): UUID version 7 for record, event and correlation ids, version 4 for tokens, version 5 for ids that must be derived the same way every time. Python (new_id, new_token, derived_id) and TypeScript (newId, newToken, derivedId) have the same three. Nothing orders by id: timestamps stay the source of truth for time. Where an id goes into a string, use ToString(), the lower-case hyphenated form every language writes.

InstanceIdProvider

The pod name (HOSTNAME) when it is set and non-empty, otherwise a random GUID fixed for the life of the process.

PortConstants
ProtoJson

The protobuf JSON mapping over runtime descriptors: InvokeJson's converter. Google.Protobuf's C# JsonParser/JsonFormatter need generated message classes, which a descriptor built from gRPC reflection does not have (C# has no DynamicMessage), so the mapping is implemented here on the wire format and checked against those reference implementations on compiled test messages (tests/Virtufin.Api.Tests/ProtoJsonConformanceTests.cs).

Encoding accepts a field by its proto name (code_source) or JSON name (codeSource) and refuses any other key. Decoding writes proto field names and default values (JsonFormatter with PreserveProtoFieldNames and FormatDefaultValues): 64-bit integers as strings, enums by name, bytes as base64, the well-known types in their JSON forms.

ProtoJsonException

A request JSON that is not the message it should be, with the JSON path of the problem.

ServiceClient

Dynamic client for invoking methods on a specific service through the gateway. Allows syntax like: client.workmanager.SomeMethod().

RPC method names are accessed as dynamic members. Each member returns a Func<Dictionary, Task<Dictionary>> that invokes the method via the Gateway's InvokeJson RPC.

ServiceClient instances are created by TryGetMember(GetMemberBinder, out object?) (i.e. client.workmanager) and cached per service name.

ServiceCollectionExtensions

Registers the gateway's typed gRPC clients for a service that calls it.

StateItemDto
Subscription

A live pub/sub subscription from SubscribeAsync(IEnumerable<string>, CancellationToken): enumerate it once with await foreach for the events, in arrival order; dispose it to end the subscription. A stream failure or cancellation is thrown from the enumeration.

Interfaces

IGatewayApi

The gateway itself: service discovery and typed dispatch to a backend service.

IInstanceIdProvider

Identifies this process among a service's replicas.

IPubsubApi

The gateway's Pubsub service: publish CloudEvents to topics and subscribe to them. A failed publish is a RpcException with an ErrorInfo; a PublishEvents call that published only some events is Aborted (PartialFailure) with a PublishEventsFailure detail.

IStateApi

The gateway's State service: per-service key/value state with etags. Every failure is a RpcException with an ErrorInfo (ErrorInfoOf(RpcException)): a missing key is NotFound; a lost compare-and-swap (an etag or createOnly write) is Aborted (Conflict); etag "0" is rejected with InvalidArgument; a bulk delete that removed only some keys is Aborted (PartialFailure) with a DeleteBulkStateFailure detail. A returned response means the write succeeded.

ITriggerApi

The gateway's Trigger service: scheduled publications to a topic (openspec item-identity). A trigger is identified by its id; a failure is an RpcException whose ErrorInfoOf(RpcException) names the reason (ErrorReasons).

IVirtufinApi

Everything a worker or a client program uses the Virtufin API for. Implemented by ApiClient over the gateway, and by in-process hosts (the worker devkit's local WorkManager) over an in-memory bus and state store, so the same worker runs in both places.