Optional writer identity (0-63). When null the server allocates the lowest free slot and surfaces it as ConvergenceClient.SourceId after connect. Set to a specific value to claim it explicitly — useful for role-mapped writers or for reconnecting to recover preserved entities. A claim conflict throws ConnectClaimConflictException.
ReadOnly
bool
false
When true the connection is read-only: it does not consume a source_id slot, is absent from the convergedb_connections system kind, and mutating calls throw ReadOnlyOperationException locally. Mutually exclusive with SourceId.
Name
string?
null
Human-readable name for this client. Visible to other clients via the convergedb_connections system kind. See Client Presence.
AuthToken
string?
null
Authentication token sent in the CONNECT frame.
LivenessDeadlineMs
uint
30000
How long the server preserves this client’s entities after disconnect before retracting them. Must be greater than HeartbeatIntervalMs.
HeartbeatIntervalMs
int
15000
How often the client sends a heartbeat to keep the connection alive.
ReconnectMaxDelayMs
int
10000
Maximum reconnection back-off delay.
SubscriberBufferSize
int
4096
Bounded capacity of each live subscription’s internal notification channel. Bootstrapping subscriptions use an unbounded buffer instead, so this does not limit how many entities can be bootstrapped.
SubscriberOverflowPolicy
SubscriberOverflowPolicy
Fault
What the SDK does when a live subscriber overflows its SubscriberBufferSize buffer. Fault (default) faults that subscription with SubscriberOverflowException so the consumer fails loudly instead of silently diverging; DropNewest silently discards the incoming notification. Applies to live state subscriptions and event subscriptions.
The requested SourceId is currently held by another live connection.
ConnectExhaustedException
ConnectAsync
All 64 source_id slots are in use; retry when a writer disconnects.
ReadOnlyOperationException
mutating SDK calls
A read-only client attempted AssertAsync / RetractAsync / PatchAsync / CreateKindAsync / EpochBeginAsync / EpochEndAsync. Also surfaced if the server rejects a mutating frame under defence-in-depth.
SubscriberOverflowException
live subscription reads (SubscribeAsync / SubscribeEventsAsync enumeration)
The subscriber fell behind and its bounded buffer overflowed under SubscriberOverflowPolicy.Fault. Buffered notifications drain first, then the read throws. Carries KindId and SubscriptionId. Dispose and re-subscribe (with bootstrap) to recover a consistent view.
Method
Returns
Description
ConnectAsync(options)
ConvergenceClient
Connect to a ConvergeDB server.
RegisterKindAsync<T>()
KindHandle<T>
Register an entity kind (writers), returns a typed handle. Storage mode (in-memory or disk-backed) is determined by the [ConvergenceEntity] attribute.
ResolveKindAsync<T>()
KindHandle<T>
Resolve a kind without mutation (readers). Validates the client’s schema is a compatible prefix of the server’s.
CreateKindAsync(name, fields)
ushort
Low-level: create entity kind, returns KindId.
GetKindAsync(name, fields)
GetKindResult
Low-level: read-only schema resolution, returns KindId + schema version + field count.
AssertAsync(kindId, entityId, fieldData)
Task
Low-level: buffer an Assert (requires FlushAsync).
PatchAsync(kindId, entityId, fieldData, mask)
Task
Low-level: buffer a Patch (requires FlushAsync).
RetractAsync(kindId, entityId)
Task
Low-level: buffer a Retract (requires FlushAsync).
FlushAsync()
Task
Flush all buffered writes. Uses a single BATCH frame when >1 op is buffered.
Batch()
ConvergenceBatch
Create a cross-kind batch that flushes on dispose.
Typed subscription yielding the next change plus those already buffered, up to maxBatch. Never waits to fill a batch; bootstrap sentinels come alone. See Subscriptions.
Batch()
KindBatch<T>
Single-kind batch that flushes on dispose.
BootstrapSnapshotAsync(ct)
IReadOnlyList<T>
One-shot bootstrap: subscribe, collect, unsubscribe. Live changes during the bootstrap are merged in.
SubscribeEventsAsync(ct)
IAsyncEnumerable<EntityEvent<T>>
Subscribe to per-assert events. The kind must have been registered with EventStream = true. Returns individual operation events (not coalesced state). No bootstrap is available since events are ephemeral. See Event Streams for details.
An in-memory copy of a kind, fed from SubscribeAsync(bootstrap: true, reconnectMode: ReconnectBootstrapMode.Full). Each bootstrap, including re-bootstraps after a reconnect, is collected into a fresh set and swapped in when it completes, so entities deleted while disconnected disappear. Live changes apply to Entries as they arrive; during a bootstrap they also enter the new set, and a snapshot row older than a live change or delete is dropped.
var mirror =new EntityMirror<ulong, Player>(id =>EntityId.ToULong(id), keep: p =>p.Online);
var changes =new List<MirrorChange<ulong, Player>>();
Committed entity version before this flush cycle. 0 for Created.
SourceId
byte
Which source (0-63) produced this operation.
Sequence
ulong
Partition-global monotonic sequence number.
Entity
T?
Deserialized assert payload (null for Retracted). This is the raw assert data, not the converged state.
PreviousEntity
T?
For Updated: previous state that ChangedFields was computed against. For Retracted: entity state before retraction. Null for Created. Forms a diff triple with Entity and ChangedFields for Updated events.
ChangedFields
ulong
Bitmask of fields changed by this assert. MaxValue for Created, 0 for Retracted.
PresenceMask
ulong
For PATCH: which fields were present.
Metadata
ReadOnlyMemory<byte>?
Opaque metadata from the assert/retract.
Method
Returns
Description
HasChanged(int fieldIndex)
bool
Check if a specific field was changed by this assert.
First assert for a previously non-existent entity.
Updated (2)
Assert that modifies an existing entity.
Retracted (3)
Source retracted its assertion. PreviousEntity contains the pre-retraction entity state.
EventType.Retracted differs from NotificationType.Deleted: a retraction event fires for every individual retract operation regardless of whether the entity dies, while a Deleted notification only fires when all sources have retracted (entity becomes tombstoned).
Generated by the source generator for each [ConvergenceEntity] struct.
Member
Kind
Description
KindName
static string
The kind name registered with the server.
Schema
static KindSchema
The field schema used for registration.
FixedFieldDataSize
static int
Size in bytes of the fixed zone (scalars, fixed-length strings/bytes, structs) plus the array directory (4 bytes per variable-length field). For kinds with no variable-length fields, this equals the total field data size.
HasVariableLengthFields
static bool
Whether this kind has any Array, VarString, or VarBytes fields.
EntityId
ReadOnlyMemory<byte>
The 32-byte entity ID.
ComputeFieldDataSize()
int
Compute the total field data size for this entity instance, including packed array/VarString/VarBytes data. For kinds with no variable-length fields, returns FixedFieldDataSize.
WriteTo(Span<byte>)
void
Serialize fields into a buffer of ComputeFieldDataSize() bytes.
When true, the server records per-assert events for this kind.
DiskBacked
bool
false
When true, entities are stored on disk with an LRU cache instead of entirely in memory. Best for kinds with large populations and small hot working sets. See Defining Entity Kinds.
CacheCapacity
uint
512
Per-partition LRU cache floor when DiskBacked = true. The cache grows adaptively if the hit rate drops below 70% but never shrinks below this value. Each partition allocates its own cache, so total cache memory scales as CacheCapacity × partition_count per kind. Ignored when DiskBacked is false.