Architecture
This page documents Orleans.Lattice.Api.Data.Grpc 10.5.0, in the documentation for Orleans.Lattice 10.5.0 (release line 10.5), built 2026-12-05. It is also published as markdown, with every table and list, at architecture.md, and llms.txt lists every page.The binding projects the in-process ILatticeDataApi facade onto a code-first gRPC service. It adds transport concerns only - wire marshalling, a coarse admission check, identity and tenant bridging, and status mapping - and delegates every operation to the facade, which in turn calls the core ILattice surface. It holds no state between calls.
Wire contract
The service is bound from C# definitions rather than a .proto file, under the gRPC service name orleans.lattice.api.data, so each method's path is /orleans.lattice.api.data/<Rpc>. The service has twelve RPCs: eleven are unary, and StreamSetMany is a duplex stream that carries a non-atomic bulk upsert as batch frames. Every message is a [GenerateSerializer] record marshalled with the Orleans binary serializer; the server and LatticeDataApiGrpcClient build their method definitions from the same serializers resolved out of a service provider, so both ends use identical marshallers. Most RPCs carry this package's Data* and Crdt* records; Get, ReadRange, DeleteRange and ProbeCapabilities reuse the facade's records from Orleans.Lattice.Api.Abstractions unchanged, and the StreamSetMany frames wrap the facade's DataEntry, DataSetManyStreamBatch and DataSetManyStreamResult. Wire aliases are pinned in GrpcDataTypeAliases and must never be renamed.
Request path
sequenceDiagram
participant C as Client
participant I as Authorization interceptor
participant S as Data-API service
participant F as ILatticeDataApi facade
participant T as ILattice tree
C->>I: RPC with metadata
I->>I: ILatticeDataApiAuthorizer (when RequireAuthorization)
I->>S: admitted call
S->>S: stamp credential and active tenant scopes
S->>F: facade verb
F->>T: core tree call (core access gate runs here)
T-->>F: result or exception
F-->>S: result or exception
S-->>C: response, or RpcException with mapped status
- Admission. A gRPC interceptor added to the host pipeline recognises calls under the
orleans.lattice.api.dataservice and ignores every other service on the host. WhenRequireAuthorizationistrue, it builds aLatticeDataApiAuthorizationContext- theServerCallContext, theLatticeDataApiOperationderived from the method name, and the target tree id taken from the request (nullfor a cross-tree batch, which spans several trees, and forStreamSetMany, whose tree rides in frames that are not read until the call is admitted) - and asksILatticeDataApiAuthorizer. A refusal ends the call withPermissionDeniedbefore the request reaches the service; a cancelled check ends it withCancelled. - Identity and tenant. The service asks
ILatticeDataApiCredentialBridgefor the caller credential andILatticeDataApiActiveTenantBridgefor an asserted tenant, and stamps each onto its ambient context for the duration of the call. A call with neither stamps nothing, so it runs as an anonymous caller in the default tenant. - Dispatch. The service unpacks the request and calls the matching facade verb.
CrdtWriteandCrdtReaddispatch on the request'sCrdtWriteOporCrdtKindto the corresponding typed CRDT verb.StreamSetManyreads one frame at a time, refuses a frame that names a different tree from the first or carries more thanDataSetManyStreamOptions.MaxBatchSizeentries (InvalidArgument), writes each frame as one batch through the facade'sSetManyStreamAsync, answers it with that batch's outcome before reading the next, and ends with a frame carrying the stream's totals - so the server holds one batch per stream. - Status mapping. Exceptions from the facade or the core tree are translated to explicit gRPC statuses. A core authorization denial becomes
PermissionDeniedwith the non-sensitive denial fields aslattice-denied-*trailers; an admission quota refusal becomesResourceExhaustedwithlattice-quota-*trailers; a schema-policy rejection becomesInvalidArgumentwith payload-freelattice-validation-*trailers. Any unmapped exception is logged server-side and returned asInternalwith a generic message. The full table is in the status mapping.
Two independent gates
The interceptor's authorizer is an endpoint-level switch: it decides whether a caller may reach the data API at all and sees only the operation and target tree. The fine-grained, per-tree and per-key rights check is the core access gate, which runs inside the tree with the identity the service stamped. Both must pass, and turning the interceptor off does not bypass the core gate. See the data facade's security notes.
Source map
- Registration
- Service and status mapping
- Method definitions
- Authorization interceptor
- Header credential bridge
- Header active-tenant bridge
- Client
- Client streamed-write driver