ClusterSchema.ts
ClusterSchema.ts overview
Section titled “ClusterSchema.ts overview”The ClusterSchema module collects the annotations that add cluster behavior
to RPC protocols and entity definitions. These annotations describe how
requests are persisted, handled in transactions, interrupted, traced, and
routed to shard groups without changing the request or response schema.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”annotations
Section titled “annotations”ClientTracingEnabled
Section titled “ClientTracingEnabled”Annotation that controls whether client-side cluster request tracing is enabled.
Details
The default value is true.
Signature
declare const ClientTracingEnabled: Context.Reference<boolean>Since v4.0.0
Dynamic
Section titled “Dynamic”Context reference for deriving request annotations from a cluster request.
When to use
Use to customize server-side request annotations based on the decoded request value.
Gotchas
This only applies to requests handled by the entity, not to the generated client.
Signature
declare const Dynamic: Context.Reference< (annotations: Context.Context<never>, request: Request<Rpc.AnyWithProps>) => Context.Context<never>>Since v4.0.0
Persisted
Section titled “Persisted”Annotation that marks whether a cluster request should be persisted in mailbox storage.
Details
The default value is false.
Signature
declare const Persisted: Context.Reference<boolean>Since v4.0.0
ShardGroup
Section titled “ShardGroup”Annotation that selects the shard group for an entity id.
Details
By default, every entity id is assigned to the "default" shard group.
Signature
declare const ShardGroup: Context.Reference<(entityId: EntityId) => string>Since v4.0.0
Uninterruptible
Section titled “Uninterruptible”Annotation that controls whether a cluster request is treated as uninterruptible.
Details
Use true for both client and server handling, "client" for client-side
handling only, "server" for server-side handling only, or false to allow
interruption.
Signature
declare const Uninterruptible: Context.Reference<boolean | "server" | "client">Since v4.0.0
WithTransaction
Section titled “WithTransaction”Annotation that marks whether request handling should be wrapped in the configured message storage transaction.
When to use
Use when you need server-side request handling or storage work wrapped in the storage transaction.
Details
The default value is false. When true, entity handling wraps server
writes with the configured storage transaction.
Gotchas
This annotation has transactional behavior only when the configured
MessageStorage implements it.
Signature
declare const WithTransaction: Context.Reference<boolean>Since v4.0.0
isUninterruptibleForClient
Section titled “isUninterruptibleForClient”Returns whether the Uninterruptible annotation applies to client-side
request handling for the provided context.
When to use
Use when you need client-side cluster request handling to decide whether to ignore an interrupt.
Details
Returns true when Uninterruptible is true or "client", and false
for "server" or the default false.
See
Uninterruptiblefor the annotation values interpreted by this helperisUninterruptibleForServerfor the server-side counterpart
Signature
declare const isUninterruptibleForClient: (context: Context.Context<never>) => booleanSince v4.0.0
isUninterruptibleForServer
Section titled “isUninterruptibleForServer”Returns whether the Uninterruptible annotation applies to server-side
request handling for the provided context.
Details
Returns true only when Uninterruptible is true or "server".
See
Uninterruptiblefor the annotation values interpreted by this helperisUninterruptibleForClientfor the client-side counterpart
Signature
declare const isUninterruptibleForServer: (context: Context.Context<never>) => booleanSince v4.0.0