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.Statuswhose details hold an ErrorInfo, carried in the standardgrpc-status-details-bintrailer (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-keyto every outbound call on the channel it is applied to. Pairs with the gateway's server-sideApiKeyInterceptor, which rejects every non-health-check call once at least one key is configured on it.
- CloudEventFactory
Builds the protobuf CloudEvents that
Pubsub.PublishEventtakes.
- CloudEvents
CloudEvents v1.0 values this codebase writes.
- ErrorReasons
The stable
google.rpc.ErrorInforeasons 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 oneErrorInfowith 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 carriedsuccess = falsewith 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.
- ProtoJson
The protobuf JSON mapping over runtime descriptors:
InvokeJson's converter. Google.Protobuf's C#JsonParser/JsonFormatterneed 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 (JsonFormatterwithPreserveProtoFieldNamesandFormatDefaultValues): 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.
- Subscription
A live pub/sub subscription from SubscribeAsync(IEnumerable<string>, CancellationToken): enumerate it once with
await foreachfor 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; aPublishEventscall that published only some events isAborted(PartialFailure) with aPublishEventsFailuredetail.
- 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 isNotFound; a lost compare-and-swap (anetagorcreateOnlywrite) isAborted(Conflict); etag"0"is rejected withInvalidArgument; a bulk delete that removed only some keys isAborted(PartialFailure) with aDeleteBulkStateFailuredetail. 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.