Services Documentation
Detailed documentation for each service component in the Virtufin API.
Table of Contents
- GatewayService
- GrpcReflectionService
- GrpcChannelPool
- PubsubService
- TopicDaprSubscriptionRegistry
- StateService
- ConfigService
- TriggerService
- ResourcesService
GatewayService
File: Services/GatewayService.cs
The central gRPC service providing gateway functionality including service discovery, method invocation, and event streaming.
gRPC Service Definition
service Gateway {
rpc Invoke (InvokeRequest) returns (InvokeResponse);
rpc InvokeJson (InvokeJsonRequest) returns (InvokeJsonResponse);
rpc ListServices (ListServicesRequest) returns (ListServicesResponse);
rpc ListMethods (ListMethodsRequest) returns (ListMethodsResponse);
rpc GetMethodSchema (GetMethodSchemaRequest) returns (GetMethodSchemaResponse);
}
Methods
Invoke
Invokes a method on a registered backend service.
public override async Task<InvokeResponse> Invoke(
InvokeRequest request,
ServerCallContext context)
Request:
- service - Target service name (e.g., "workmanager")
- method - Method name to invoke
- requestData - JSON payload for the request
Response:
- success - Boolean indicating success
- status - gRPC status code string
- message - Error message if failed
- responseData - JSON response payload
- statusDetails - On a failure, the encoded google.rpc.Status with its ErrorInfo (Errors)
InvokeJson
Invokes a method on a registered backend service using JSON request/response data. The recommended method for most use cases.
public override async Task<InvokeJsonResponse> InvokeJson(
InvokeJsonRequest request,
ServerCallContext context)
Request:
- service - Target service name (e.g., "workmanager")
- method - Method name to invoke
- requestData - JSON payload for the request (as a string)
Response:
- success - Boolean indicating success
- status - gRPC status code string
- message - Error message if failed
- responseData - JSON response payload (as a string)
- statusDetails - as for Invoke
InvokeJsonStream
Relays a backend's server-streaming method as JSON (openspec api-gateway, Streaming JSON Invocation): the same InvokeJsonRequest as InvokeJson, then one InvokeJsonResponse (success, status OK, response_data) per backend message until the backend ends the stream. Canceling the call cancels the backend call.
public override async Task InvokeJsonStream(
InvokeJsonRequest request,
IServerStreamWriter<InvokeJsonResponse> responseStream,
ServerCallContext context)
Refusals are gRPC statuses, not in-band answers: INVALID_ARGUMENT for a unary, client-streaming or bidirectional method or a request that does not parse, NOT_FOUND for an unknown service or method, UNAVAILABLE when the backend's descriptors cannot be loaded; a backend failure mid-stream ends it with the backend's status. No default deadline and no retries.
ListServices
Lists all services registered in the gateway configuration.
public override async Task<ListServicesResponse> ListServices(
ListServicesRequest request,
ServerCallContext context)
Response:
- services - List of service name strings
ListMethods
Lists all methods available on a specific service.
public override async Task<ListMethodsResponse> ListMethods(
ListMethodsRequest request,
ServerCallContext context)
Request:
- service - Service name to query
Response:
- methods - List of MethodInfo objects with name, input/output types, streaming flags
and kind
Kind (openspec api-gateway, Method Kinds): METHOD_KIND_READ when the method's
descriptor marks it option idempotency_level = NO_SIDE_EFFECTS; or it belongs to the standard
health service grpc.health.v1.Health (each backend's Check), else when its name starts
with List or Get followed by a capital letter; METHOD_KIND_WRITE otherwise. Clients take
a backend method's kind from here and keep no rule of their own. Mark a backend's reads in its
proto, so a read whose name is not List…/Get… is reported as one:
rpc ListWorkers (ListWorkersRequest) returns (ListWorkersResponse) {
option idempotency_level = NO_SIDE_EFFECTS;
}
Special Handling:
For virtufin.Gateway or Gateway, returns the built-in gateway methods directly.
GetMethodSchema
Returns the schema for a specific method including input/output types and field definitions.
public override async Task<GetMethodSchemaResponse> GetMethodSchema(
GetMethodSchemaRequest request,
ServerCallContext context)
Request:
- service - Service name
- method - Method name
- type - Schema type to return (typically "input" or "output")
Response:
- schema - MethodSchema object with input_type_name, output_type_name, schema_type, and fields (list of FieldSchema with name, type, type_name, is_repeated, is_optional, oneof_group, oneof_cases)
Used by clients to introspect a service's wire format before calling it.
Note:
Gatewayhas noSubscribeRPC. Event streaming lives on thePubsubservice (Pubsub.Subscribe, topic-filtered only) — see PubsubService and events.md. TheWatchSystemEventsRPC was also removed; per-service lifecycle events are delivered throughPubsub.Subscribeon the appropriate per-service topic (e.g.sys.workmanager.worker.lifecycle, which also carries a WebSocketFeed worker's connection status).
GrpcReflectionService
File: Services/GrpcReflectionService.cs
Provides dynamic gRPC service discovery and invocation using the gRPC Reflection protocol.
Key Classes
| Class | Purpose |
|---|---|
GrpcReflectionService |
Public API, manages per-service caches |
ServiceDescriptorCache |
Per-service descriptor caching and loading |
ServiceMethodInfo |
Method metadata storage |
MethodSchema |
Request/response schema |
FieldSchema |
Field definition |
GrpcCallResult |
Invocation result wrapper |
Public API
GetMethodsAsync
public async Task<List<ServiceMethodInfo>> GetMethodsAsync(
string serviceName,
CancellationToken cancellationToken = default)
Returns all methods for a service discovered via reflection.
GetMethodSchemaAsync
public async Task<MethodSchema?> GetMethodSchemaAsync(
string serviceName,
string methodName,
string? type = null,
CancellationToken cancellationToken = default)
Returns the schema for a method's input or output type.
Parameters:
- serviceName - Service to query
- methodName - Method name
- type - "input" or "output" (default: input)
ExecuteCallAsync
public async Task<GrpcCallResult> ExecuteCallAsync(
string serviceName,
string methodName,
string requestJson,
Dictionary<string, string>? metadata = null,
CancellationToken cancellationToken = default)
Executes a gRPC call by name using reflection data.
Returns: GrpcCallResult with:
- Success - Boolean
- StatusCode - gRPC status
- Message - Error detail
- Data - Response JSON
GetFileDescriptorProtosAsync
public async Task<List<ByteString>> GetFileDescriptorProtosAsync(
string serviceName,
CancellationToken cancellationToken = default)
Returns raw protocol buffer descriptors for the service.
Internal Processing
ServiceDescriptorCache
Manages the cached state for a single service:
- Lazy Loading: Descriptors loaded on first access
- Thread-Safe: Uses locking for initialization
- Descriptor Building: Parses FileDescriptorProtos and builds indexes
- Cache staleness: The cache has no TTL and no invalidation mechanism. If a backend service redeploys with a changed proto schema, the gateway will serve stale descriptors until it restarts. This is a known limitation (tracked as P2-1). In production, restart the gateway after any backend service redeploy that changes proto schemas. A configurable TTL (
REFLECTION_CACHE_TTL_SECONDS) and an invalidation endpoint are planned.
JSON↔Protobuf Conversion
The service handles conversion between JSON and protobuf:
Request (JSON → Protobuf):
1. Try JsonParser.Default.Parse() (preferred)
2. Fall back to field-by-field parsing
Response (Protobuf → JSON):
1. Try msgDesc.Parser.ParseFrom()
2. Fall back to field-by-field binary reading
Well-Known Descriptors
Includes google/protobuf/descriptor.proto, which backend reflection servers
don't return; it is the dependency of any proto declaring custom options.
GrpcChannelPool
File: Services/GrpcChannelPool.cs
Thread-safe pool of gRPC channels organized by service name.
Public API
public GrpcChannel GetChannel(string serviceName)
Gets or creates a gRPC channel for the specified service.
Parameters:
- serviceName - Service name from configuration
Returns: GrpcChannel for the service
Throws: ArgumentException if service not found in configuration
Channel Management
- Lazy Creation: Channels created on first access
- Reuse: Same channel returned for repeated calls to same service
- Lifecycle: All channels disposed on
Dispose()
Configuration Integration
Channels are created using service configuration:
services:
- name: workmanager
protocol: grpc
grpc:
host: localhost
port: 5002
pubsub:
pubsubName: pubsub
state:
storeName: statestore
jobs:
crons: []
Hard requirement: Every service in the configuration must implement gRPC reflection. When a gRPC channel is created for a service, the API Gateway probes for reflection support. If reflection is not available, an
InvalidOperationExceptionis thrown — the channel is not created and the service cannot be proxied. Ensure all backend services register gRPC reflection viaGrpc.AspNetCore.Server.Reflection.
Channel address: http://{host}:{port}
PubsubService
File: Services/PubSubService.cs
Provides pub/sub messaging operations using Dapr pub/sub. Implements the Pubsub gRPC service defined in Protos/pubsub.proto.
gRPC Service Definition
service Pubsub {
rpc PublishEvent (PublishRequest) returns (PublishResponse);
rpc PublishEvents (PublishEventsRequest) returns (PublishEventsResponse);
rpc Subscribe (SubscribeRequest) returns (stream SubscribeResponse);
rpc ListTopics (ListTopicsRequest) returns (ListTopicsResponse);
}
Methods
PublishEvent
Publishes an event to a Dapr topic.
public override async Task<PublishResponse> PublishEvent(
PublishRequest request,
ServerCallContext context)
Request:
- topic - The topic name to publish to
- cloudevent - The CloudEvent message (CloudNative.CloudEvents.V1.CloudEvent proto)
Response: empty. An OK status means the event was published; a failure is a gRPC
status with an ErrorInfo (Errors): INVALID_ARGUMENT naming the field, or
UNAVAILABLE naming the topic.
PublishEvents
Publishes up to 1000 events in one call. The call costs one publish per topic, not one per event.
- Each topic's events are published in the given order; different topics in parallel.
- A topic's events of the call are stored together as one stream entry, a
batch entry (see How events are stored). They are
split over several entries when they exceed
PubsubBatchEntryMaxEvents(default 1000) orPubsubBatchEntryMaxBytes(default 768 KiB). - Every event is validated first; an invalid one rejects the whole call
(
InvalidArgument, itsErrorInfonaming the fieldevents[i]…) before anything is published. - A stream entry that cannot be published doesn't stop later entries of its topic.
The call answers OK, with
published, only when every event was published; otherwise it fails withABORTED(reasonPARTIAL_FAILURE) and aPublishEventsFailuredetail listingpublishedand thefailed_indexes(every event of each entry that failed).
This is not Dapr's bulk publish: on Redis Streams that publishes a batch's events in parallel, with no ordering guarantee.
How events are stored
Every event is stored in the stream as a protobuf CloudEvent
(application/cloudevents+protobuf, the
CloudEvents protobuf format),
whatever its data: binary_data, text_data or proto_data. No event passes
through JSON, so binary payloads such as the FlatBuffers order book image are
never base64-encoded and a proto_data message arrives as it was sent.
- An attribute arrives in the type its publisher sent it in:
ce_string,ce_integer,ce_boolean,ce_bytes,ce_uri,ce_uri_reforce_timestamp. - The one exception is
time. Sent as a string, it is stored as a timestamp, so a subscriber always finds an event's time ince_timestamp. Atimethat is not RFC 3339 is refused (InvalidArgument). - The gateway's own events (state changes, trigger firings, the topic catalog) are stored the same way.
- Subscriptions read entries as stored (
rawPayload). An entry that is not a protobuf CloudEvent, written by something other than the gateway, is delivered as an event of typeunknownwith the entry as its binary data.
A batch entry holds the events one PublishEvents call carries for one
topic: a protobuf CloudEvent of type com.virtufin.api.pubsub.batch.packed
whose binary data is the list of events, each encoded exactly as it would be
stored on its own. That data is, byte for byte, an encoded
io.cloudevents.v1.CloudEventBatch.
- By default the gateway unpacks a batch entry on delivery and on replay, so a subscriber receives the single events, in order.
- A subscriber that sets
accept_batchesreceives the entry's data whole, inSubscribeResponse.batch(see Subscribe). The gateway then forwards the stored bytes without reading the events. - The type is reserved: publishing an event of that type is refused
(
InvalidArgument). - A reader of the stream that does not go through the gateway sees the batch entry as one event.
Subscribe
Subscribes to topics and streams their events as they arrive. Topics are created dynamically (no configuration needed).
public override async Task Subscribe(
SubscribeRequest request,
IServerStreamWriter<SubscribeResponse> responseStream,
ServerCallContext context)
Request:
| Field | Meaning |
|---|---|
topics |
The topics to subscribe to. |
replay_since |
Deliver what each topic's stream still retains from this time on before the live events. Unset: start at the tail. |
replay_only |
With replay_since: deliver the retained entries, then end the call. |
announce_live |
Ask for a first response with live = true once every topic is subscribed. |
accept_batches |
Take a batch entry as one response instead of one response per event. |
Response: a stream of SubscribeResponse messages. Each carries one of:
| Field | Meaning |
|---|---|
topic + cloudevent |
One event (io.cloudevents.v1.CloudEvent). |
topic + batch |
Only with accept_batches: the events of one batch entry, in order, as an encoded io.cloudevents.v1.CloudEventBatch. |
live |
Only with announce_live, on the first response: the subscription is live. No topic, no event. |
Whole batches (accept_batches). For a subscriber that takes events in
bulk, such as the WorkManager Runtime.
- The events and their order are the same as without the field. Only the
grouping differs: the events one
PublishEventscall sent for a topic arrive as one response. - An event stored alone still arrives in
cloudevent, so such a subscriber handles both shapes. batchisbytes, not aCloudEventBatchfield, on purpose. Neither the gateway nor the client's generated stub parses events that are only passed on. Parse the bytes withCloudEventBatchwhere the events are needed.- On a live call with
replay_sinceevery response is a single event. The gateway recognizes a live event the replay already delivered by its id, and for that it reads the events. - With
replay_onlythe retained entries arrive as stored. The bounds (PubsubReplayMaxEntries,PubsubReplayMaxBytes) still count events.
ListTopics
Lists the topics seen at the gateway, sorted by name.
Dapr's pubsub API cannot list topics, and asking the broker would tie the
gateway to one pubsub component. Every publish and subscribe passes through the
gateway, so it records the names itself (TopicCatalog): PublishEvent,
PublishEvents, state change events and trigger firings count as published,
Subscribe as subscribed. The record is one state-store key,
sys.api.topic.catalog, written with the same ETag-guarded operations as the
publication fence, so any Dapr state store with ETags and transactions works.
- Each replica notes a topic at most once a minute per use, in memory, and merges what it noted into the record every 5 seconds; times are precise to about a minute.
- A topic drops out after 7 days unseen.
- Per-run reply topics (
rpc.<caller>.reply.<run_id>) are not recorded. - A topic appears only once traffic has passed through the gateway; a component publishing to Dapr directly is invisible.
- Topics new to the record are announced on
sys.api.topic.catalog.added(com.virtufin.api.topic.catalog.added, data{topics: [...]}), one event per merge that added any, by the replica whose write added them (api#56). A client keeps its list current from these instead of asking again; like the state-change events they are best effort, so it lists again after it resubscribes.
Response: topics, each a TopicInfo with topic, last_published and
last_subscribed (timestamps, unset if never seen that way).
TopicDaprSubscriptionRegistry
File: Services/TopicDaprSubscriptionRegistry.cs
The in-process fan-out broker. Dapr pub/sub is competing-consumer, so the gateway holds one Dapr subscription per topic per process and writes each message to every subscriber itself.
AcquireAsync(topic, buffer, acceptBatches, onActive, ct)adds a Subscribe call's buffer as a subscriber, opening the topic's Dapr subscription for the first one;onActivefires once it is open.acceptBatchessays whether the subscriber takes a batch entry whole. An entry's two shapes (one response per event, one response for the entry) are each built at most once, and only when a subscriber needs them. Disposing the returned handle removes the subscriber; the last one leaving closes the Dapr subscription.- The Dapr subscription runs on its own token: the subscriber that opened it may leave first without ending it for the others.
- If the Dapr subscription ends on its own, every subscriber's buffer completes with
Unavailable; the next Subscribe opens a fresh one. - Delivery never waits for a subscriber and never drops its events. Each subscriber
buffers 1024 events (
SubscriberBuffer). A whole batch takes the room of the events it holds, so the bound is the same for both shapes; a batch larger than the free room is taken only when the buffer is empty. One whose buffer cannot take an entry leaves live delivery and is served by a reader of its own from the topic's stream, which waits for room as long as it takes: the rest of that entry, the entries the sidecar holds unhandled, then the stream from the sidecar's position on. - At the stream's end the reader hands the subscriber back to live delivery, together with the entries it gave that live delivery still brings; those are passed over once. So a subscriber gets every event, each once in the normal case; where that cannot be told (an event without an id), the error is a duplicate, never a loss.
-
The call of a subscriber that cannot be served ends with a status that says why:
Status Meaning DataLossIt is behind further than the stream reaches back ( streamTTL): events are missing.ResourceExhaustedIt took nothing for PubsubSubscriberStallSeconds(default 300), or its backlog cannot be read: the backend has no stream the gateway reads (Redis withPubsubRedisHost, NATS JetStream withPubsubNatsUrl), or more than 1000 entries are pending in the sidecar (on JetStream: not yet acknowledged by its consumer, so keep the component'smaxAckPendingbelow 1000).UnavailableThe Dapr subscription ended, or reading the stream failed. -
SubscriptionHealthSweeperHostedServiceprobes every subscriber with a heartbeat each minute and ends the call of one whose full buffer took no write forPubsubSubscriberStallSeconds: a client that is gone or stuck. One that is merely behind keeps taking writes and stays. - A read of the stream takes about 1 MiB (16 entries at first, at most 128), so a catch-up costs the gateway a bounded amount of memory per subscriber.
ConfigService
File: Services/ConfigService.cs
Exposes the service registry configuration — which services are registered, their gRPC
endpoints, and their pubsub / state component names — to admin and observability clients.
Implements the Config gRPC service defined in Protos/config.proto.
One caveat on what this reports.
dapr_app_idwas removed fromConfigService: routing is a direct gRPC dial togrpc.host/grpc.port, never Dapr service invocation.pubsub.pubsub_nameis honored, but as a gateway-wide setting rather than a per-service one — see events.md.
gRPC Service Definition
service Config {
rpc ListServices (ListConfigServicesRequest) returns (ListConfigServicesResponse);
rpc GetService (GetConfigServiceRequest) returns (GetConfigServiceResponse);
}
Methods
ListServices
Returns all services registered in services.json, each with its Dapr app-id, gRPC host/port, pubsub component name, state store name, and scheduled cron jobs.
Response: ListConfigServicesResponse.services — list of ConfigService protos with name, grpc.{host,port}, pubsub.pubsub_name, state.store_name, jobs.crons[].
GetService
Returns a single service by name, or an empty Service field if not found.
Request: GetConfigServiceRequest.name — service name to look up.
Response: GetConfigServiceResponse.service — ConfigService proto, or unset if the service is not registered.
StateService
File: Services/StateService.cs
Provides state management using the Dapr state store. Implements the State gRPC service
defined in Protos/state.proto.
gRPC Service Definition
service State {
rpc SaveState (SaveStateRequest) returns (SaveStateResponse);
rpc GetState (GetStateRequest) returns (GetStateResponse);
rpc DeleteState (DeleteStateRequest) returns (DeleteStateResponse);
rpc QueryState (QueryStateRequest) returns (QueryStateResponse);
rpc GetBulkState (GetBulkStateRequest) returns (GetBulkStateResponse);
rpc DeleteBulkState (DeleteBulkStateRequest) returns (DeleteBulkStateResponse);
}
message SaveStateRequest {
string service = 1;
string key = 2;
string value = 3; // MUST be valid JSON
string etag = 4;
bool publish_change = 5; // publish a state change event after the write
bool include_value = 6; // include the value in that event
int32 ttl_seconds = 7;
bool create_only = 8; // succeed only if the key does not already exist
}
See proto/state.proto for the full message set.
What service means
service selects the Dapr state store to use, via a lookup in the gateway's
services.json. It must be non-empty and must name a registered service; the match is
exact and case-sensitive, so WorkManager is rejected where workmanager is accepted.
service is not an isolation boundary. The API does not check that key begins with
service, QueryState filters are not scoped to the caller's prefix, and all registered
services currently share one store. Keys follow the {service}.{entity}.{id} convention by
caller-side discipline — see AGENTS.md
for the full convention and its limits.
ETag and Optimistic Concurrency
| Scenario | Behavior |
|---|---|
| No ETag provided | Last-write-wins. The write always succeeds. |
| Matching ETag | Write succeeds. State is updated. |
| Mismatched ETag | Fails with StatusCode.Aborted. Re-read and retry. |
create_only: true, empty ETag |
Succeeds only if the key does not exist; otherwise Aborted, on every store. |
ETag the store cannot parse ("abc" on Redis, whose ETags are numbers) |
Fails with InvalidArgument, naming the bad value. Pass an ETag GetState returned. |
An ETag of "0" is rejected with InvalidArgument — it is the Redis component's
force-write sentinel and would silently defeat the compare-and-swap.
var current = await client.GetStateAsync("workmanager", "sys.workmanager.worker.abc123");
await client.SaveStateAsync("workmanager", "sys.workmanager.worker.abc123", newValue,
etag: current.Etag);
// Throws RpcException with StatusCode.Aborted if the ETag doesn't match.
QueryState
QueryState takes Dapr's query-state JSON DSL and passes it to the store. The store keeps
each value as text (so its numbers and key order survive, see Value fidelity),
so a filter cannot match fields inside a value: query everything and filter by key.
{"filter": {}}
{"filter": {}, "page": {"limit": 50}}
It requires a store whose Dapr component implements the Query API. For Redis/Valkey that
means the RediSearch module must be loaded and the component must declare
queryIndexes metadata; without both, every query fails — including Dapr's "{}"
match-everything query. Use GetBulkState against known keys as the fallback.
limit goes to the store as the query's page.limit, so the store returns at most that many
rows.
The answer holds state documents only, that is, values saved through this service. A store's
query can return other rows: state.postgresql returns every row of its table, among them
the gateway's own records (the topic catalog, the publication fences) and other apps' rows.
The gateway leaves those out. They still count towards the store's page.limit, so on such a
store an answer can hold fewer items than limit while more documents exist. On
state.redis the query index holds state documents only. state.postgresql also returns a
key whose time to live has passed until Dapr deletes its row (the component's
cleanupInterval, one hour by default); GetState answers NotFound for it at once.
Value fidelity
A value comes back byte for byte as it was saved: the same digits and the same key order.
The gateway stores it as a JSON string inside the document, {"virtufin.json": "<value>"},
because daprd's Redis JSON path re-marshals anything else with at most 6 decimals and in
random key order (api#52). A document without it (the value itself, as gateways before
0.15.10 stored it) is an internal error for GetState and GetBulkState, and logged: none
are left since api#54. QueryState leaves such a row out.
State Change Broadcasting
SaveState, DeleteState and DeleteBulkState publish a change event only when the
request sets publish_change: true. Events go to the global topics sys.api.state.saved and sys.api.state.deleted,
not to a per-service topic; the payload carries service, key (or keys), and
action ("save" or "delete").
Setting include_value: true adds the value to that payload — and therefore broadcasts it
to every subscriber of those topics, platform-wide. See events.md.
Error reporting
Every failure is a gRPC status with an ErrorInfo (Errors); an OK status means
the call succeeded:
| Failure | Status | Reason |
|---|---|---|
| A missing or malformed field, an unregistered service | INVALID_ARGUMENT |
INVALID_FIELD, with the field |
A lost compare-and-swap (a stale ETag, create_only on a key that exists) |
ABORTED |
CONFLICT, with the key |
A missing key (GetState, a conditional delete) |
NOT_FOUND |
NOT_FOUND, with the key |
DeleteBulkState that deleted only some keys |
ABORTED |
PARTIAL_FAILURE, with a DeleteBulkStateFailure detail naming the failed_keys |
| The store failed | INTERNAL |
INTERNAL |
TriggerService
File: Services/TriggerService.cs
Wraps Dapr's Scheduler API to schedule triggers, identified by id, with tags, groups and an
owner kept next to the job. When a trigger fires, DaprAppCallbackService publishes an
empty CloudEvent to the trigger's target_topic via Dapr pub/sub. Ids, tags, groups, the
owner and how they are stored: Triggers.
gRPC Service Definition
service Trigger {
rpc ScheduleTrigger (ScheduleTriggerRequest) returns (ScheduleTriggerResponse); // {id}
rpc GetTrigger (GetTriggerRequest) returns (GetTriggerResponse);
rpc DeleteTrigger (DeleteTriggerRequest) returns (DeleteTriggerResponse);
rpc ListTriggers (ListTriggersRequest) returns (ListTriggersResponse);
rpc UpdateTriggerTags (UpdateTriggerTagsRequest) returns (UpdateTriggerTagsResponse);
// For the WorkManager:
rpc AddTriggerToGroup (AddTriggerToGroupRequest) returns (AddTriggerToGroupResponse);
rpc RemoveTriggerFromGroup (RemoveTriggerFromGroupRequest) returns (RemoveTriggerFromGroupResponse);
rpc ClearTriggerOwner (ClearTriggerOwnerRequest) returns (ClearTriggerOwnerResponse);
}
Key Behavior
scheduleis a 6-field cron expression or an@everyduration.ScheduleTriggeranswers the trigger's id: the given one, or a generated UUID of version 7. A given id that exists fails withALREADY_EXISTS(reasonID_EXISTS). When the scheduler's own retry finds this call's first write (an etcd stall, api#53), the call succeeds: the job carries the call's schedule token.- Tag, group and owner changes never reschedule the job: the next firing stays.
- Every failure is a gRPC status with an
ErrorInfo(Errors); an emptyListTriggersmeans there are no triggers. - Trigger delivery arrives on Dapr's
AppCallback/OnJobEventroute, implemented byDaprAppCallbackServiceand bound to the stable route byDaprStableAppCallbackMethodProvider.
ResourcesService
virtufin.Resources (resources.proto) answers how much CPU, memory and data the context's backends use, read from Prometheus (openspec api-gateway, Backend Resources). Which backends exist, and which pods make up each, comes from resources.json (Configuration). Clients never send queries.
Methods
ListBackends
Returns every configured backend in the order of resources.json:
| Field | Meaning |
|---|---|
name, roles |
The backend and what the context uses it for (pubsub, state, eventstore, …) |
pods[].name, pods[].namespace |
Each running pod whose whole name matches the backend's pattern |
pods[].cpu_cores |
CPU in use, averaged over rateWindow |
pods[].memory_bytes |
Memory working set |
pods[].cpu_request_cores, cpu_limit_cores, memory_request_bytes, memory_limit_bytes |
Sums over the pod's containers that set them; unset when none does |
data_bytes |
The sum of the backend's dataBytesQuery; unset without one |
volumes[] |
The persistent volumes the backend's pods mount, by claim (openspec api-gateway, Backend Storage) |
volumes[].namespace, claim, storage_class |
The PersistentVolumeClaim |
volumes[].disk |
Where it lives: <nfs server>:<export> (the first nfsExportDepth path segments) or node <name> for a local volume |
volumes[].used_bytes |
The volume directory's size as the disk-usage collector measured it (volumeUsedMetric); unset when not measured |
volumes[].unmeasured_reason |
Why used_bytes is unset: no PersistentVolume, no NFS or local path, or no figure for the path |
volumes[].growth_bytes_per_day |
The change of used_bytes per day over growthWindow; unset until two measurements |
volumes[].disk_size_bytes, disk_available_bytes |
The kubelet's figures for the claim: those of the whole filesystem, the disk |
Without resources.json the call fails with FAILED_PRECONDITION ("resources are not configured"); when Prometheus refuses a configured query, also FAILED_PRECONDITION with its error; when Prometheus cannot be reached within queryTimeoutSeconds, UNAVAILABLE.
The kubelet's volume figures are never used for a volume's size: no storage class on medusa enforces one, so every NFS volume reports the whole export and every local volume its node's disk. They describe the disk; a volume's size comes only from the disk-usage collector, which measures the volume's directory (disk_usage_exporter, deployed by k3s-common's virtufin_backend role). The sources are kube-state-metrics (kube_pod_spec_volumes_persistentvolumeclaims_info, kube_persistentvolumeclaim_info, kube_persistentvolume_info) and the kubelet (kubelet_volume_stats_capacity_bytes, _available_bytes).
grpcurl -H "x-api-key: $KEY" api.virtufin.com:443 virtufin.Resources/ListBackends