serverpod_offline_sync library

Classes

BaseHlc
Base class for HLC timestamps.
CrdtDatabase
Database proxy that runs insert/update/delete ORM operations inside a transaction to record each change in the CRDT tables.
CrdtDatabaseContext
Process-level CRDT database metadata shared by ephemeral database wrappers.
CrdtDatabaseSession
Wraps a DatabaseSession to provide a CrdtDatabase as DatabaseSession.db.
CrdtDataDeleted
CRDT visibility generation table.
CrdtDataDeletedAttachRowRepository
CrdtDataDeletedInclude
CrdtDataDeletedIncludeList
CrdtDataDeletedRepository
CrdtDataDeletedTable
CrdtDataDeletedUpdateTable
CrdtDataField
CRDT data table.
CrdtDataFieldAttachRowRepository
CrdtDataFieldDetachRowRepository
CrdtDataFieldInclude
CrdtDataFieldIncludeList
CrdtDataFieldRepository
CrdtDataFieldTable
CrdtDataFieldUpdateTable
CrdtDataForeignKey
CRDT field foreign key value and projection table.
CrdtDataForeignKeyAttachRowRepository
CrdtDataForeignKeyInclude
CrdtDataForeignKeyIncludeList
CrdtDataForeignKeyRepository
CrdtDataForeignKeyTable
CrdtDataForeignKeyUpdateTable
CrdtDataRow
CRDT data rows table.
CrdtDataRowAttachRepository
CrdtDataRowAttachRowRepository
CrdtDataRowInclude
CrdtDataRowIncludeList
CrdtDataRowRepository
CrdtDataRowTable
CrdtDataRowUpdateTable
CrdtMergeChange
A remote CRDT change to merge.
CrdtMergeDelete
A remote visibility CLFlag update to merge.
CrdtMergeInsert
A remote row insertion to merge.
CrdtMergeUpdate
A remote field update to merge.
CrdtMutationRecorder
Persists additional CRDT rows after a mutating ORM operation completes.
CrdtNode
CRDT nodes table.
CrdtNodeInclude
CrdtNodeIncludeList
CrdtNodeRepository
CrdtNodeTable
CrdtNodeUpdateTable
CrdtSchemaColumn
CRDT schema columns table.
CrdtSchemaColumnAttachRowRepository
CrdtSchemaColumnInclude
CrdtSchemaColumnIncludeList
CrdtSchemaColumnRepository
CrdtSchemaColumnTable
CrdtSchemaColumnUpdateTable
CrdtSchemaRegistry
Manages the CRDT schema for a database.
CrdtSchemaTable
CRDT schema tables table.
CrdtSchemaTableInclude
CrdtSchemaTableIncludeList
CrdtSchemaTableRepository
CrdtSchemaTableTable
CrdtSchemaTableUpdateTable
CrdtScope
CRDT scopes table.
CrdtScopeAttachRepository
CrdtScopeAttachRowRepository
CrdtScopeDetachRowRepository
CrdtScopeGrant
A single scope a peer announces in a CrdtSyncScopeSet.
CrdtScopeInclude
CrdtScopeIncludeList
CrdtScopeManager
A manager for CrdtScope instances.
CrdtScopeMember
Authorization membership for shared CRDT scopes.
CrdtScopeMemberAttachRowRepository
CrdtScopeMemberInclude
CrdtScopeMemberIncludeList
CrdtScopeMemberRepository
CrdtScopeMembership
Resolves shared-scope membership from the crdt_scope_members table.
CrdtScopeMemberTable
CrdtScopeMemberUpdateTable
CrdtScopeNode
A CRDT node's participation and checkpoint state within one scope.
CrdtScopeNodeAttachRowRepository
CrdtScopeNodeInclude
CrdtScopeNodeIncludeList
CrdtScopeNodeRepository
CrdtScopeNodeTable
CrdtScopeNodeUpdateTable
CrdtScopeRepository
CrdtScopeTable
CrdtScopeUpdateTable
CrdtSync
The shared CRDT synchronization logic used by both client and server nodes.
CrdtSyncClient
High-level client sync helpers built on top of a CRDT stream transport.
CrdtSyncClose
Marks a graceful end of a one-shot sync session.
CrdtSyncConnect
Session handshake sent once by each peer before any scope work.
CrdtSyncCycleBatch
One sync cycle's inbound frames.
CrdtSyncEndOfBatch
Marks the end of a framed sync batch.
CrdtSyncIdleTimeout
Marks a timeout of an idle sync session.
CrdtSyncIntegrityViolation
Durable record of a terminal CRDT sync integrity violation.
CrdtSyncIntegrityViolationInclude
CrdtSyncIntegrityViolationIncludeList
CrdtSyncIntegrityViolationRepository
CrdtSyncIntegrityViolationTable
CrdtSyncIntegrityViolationUpdateTable
CrdtSyncMergeChunk
A chunk of merge changes carried inside a framed sync batch.
CrdtSyncScopeSet
Authoritative or informational scope set exchanged at the start of a cycle.
CrdtSyncSession
A running continuous CRDT sync session.
CrdtSyncSinceHlc
Per-scope checkpoint sent by each peer before the first visit to a scope.
CrdtSyncStreamEvent
A CRDT sync event sent over a bidirectional stream.
Hlc
A Hybrid Logical Clock implementation that supports both ISO 8601 and Unix timestamp formats. The datetime component has millisecond precision and is always stored in UTC.
HlcManager
A manager for Hlc instances that is used to generate unique timestamps for CRDT operations.
Protocol

Enums

CrdtDataDeletedReason
Why a synced user tombstone changed row visibility.
CrdtDataRowVisibility
Materialized visibility state for a CRDT row.
CrdtForeignKeyOverrideReason
Why a foreign key projection override is active.
CrdtScopeRole
CRDT access role for a member of a shared scope.
CrdtSyncPeerMode
How a peer decides which scopes it syncs.
CrdtSyncViolationOperation
Merge or sync operation that observed an integrity violation.
CrdtSyncViolationType
High-level category of a durable CRDT sync integrity violation.

Extensions

BaseHlcToHlc on BaseHlc
Extensions for BaseHlc to convert it to an Hlc.
CrdtDatabaseAccess on DatabaseSession
Convenience access to a CRDT-aware database from a wrapped session.
CrdtDataDeletedExtension on CrdtDataDeleted
Extensions for the CrdtDataDeleted class.
CrdtDataDeletedReasonExtension on CrdtDataDeletedReason
Extensions for the CrdtDataDeletedReason enum.
CrdtDataFieldExtension on CrdtDataField
Extensions for the CrdtDataField class.
CrdtDataForeignKeyExtension on CrdtDataForeignKey
Extensions for the CrdtDataForeignKey class.
CrdtDataRowExtension on CrdtDataRow
Extensions for the CrdtDataRow class.
CrdtDataRowVisibilityExtension on CrdtDataRowVisibility
Extensions for the CrdtDataRowVisibility enum.
CrdtMergeChangeExtension on CrdtMergeChange
Convenience helpers shared by every merge change.
CrdtMergeChangeStreamExtension on Stream<CrdtMergeChange>
Helpers for grouping merge changes into stream payload batches.
CrdtMergeInsertExtension on CrdtMergeInsert
Convenience helpers for insert changes.
CrdtMergeRecorderExtension on CrdtMutationRecorder
Adds merge-specific behavior to CrdtMutationRecorder.
CrdtMergeSetExtension on CrdtMergeSet
CRDT merge helpers for CrdtMergeSet.
CrdtScopeRoleWriteAccess on CrdtScopeRole?
CRDT write capability for a scope role.
CrdtSyncStreamEventStreamExtension on StreamIterator<CrdtSyncStreamEvent>
Extensions for stream iterators of CrdtSyncStreamEvent.
HlcMax on Iterable<Hlc>
Extensions for an Iterable of Hlc.
IncludeTombstonedRows on Table
Extension on Table that exposes includeHiddenRows for use in where clauses to bypass the CRDT tombstone/visibility filter.
ScopeUuidFilter on Table
Extension on Table that exposes scopeEquals for use in where clauses to restrict membership-wide reads to a single scope.

Properties

crdtRowLastVisibleVisibilityIndex int
Last serialized index that still represents a visible CRDT row.
final
scopeForTransaction Map<Transaction, CrdtScope>
Map of transaction hashes to the scope they are associated with.
final
userForTransaction Map<Transaction, UuidValue>
Map of transaction hashes to the authenticated user associated with them.
final

Typedefs

CrdtMergeMetadataLookup = ({Map<String, Set<String>> columnNamesByTable, Map<String, Set<UuidValue>> rowIdsByTable})
Merge metadata extracted from a CrdtMergeSet.
CrdtMergeSet = List<CrdtMergeChange>
A group of CRDT merge changes collected for one sync batch.
CrdtSyncOnMergeSuccess = FutureOr<void> Function(UuidValue scopeUuid, Hlc syncedHlc)
Callback function for when a merge is successful.
CrdtSyncTransport = Stream<CrdtSyncStreamEvent> Function({required Stream<CrdtSyncStreamEvent> changes, required bool once})
Opens the remote half of a CRDT sync stream.
DomainRowOwner = ({bool exists, int? scopeId})
A tuple representing the ownership of a domain row.
DomainRowOwnerCache = Map<(String, UuidValue), DomainRowOwner>
A cache of domain row owners by table name and row id.

Exceptions / Errors

ClockDriftException
Exception thrown when the clock drift exceeds the maximum allowed.
CrdtScopeMembershipException
Thrown when a user attempts to act in a scope they are not a member of.
CrdtScopeRoleException
Thrown when a user attempts to write in a scope with a non-writable role.
CrdtSyncException
Base type for CRDT sync session failures.
CrdtSyncIntegrityViolationException
Thrown when sync observes terminal CRDT metadata/domain-row inconsistency.
CrdtSyncStreamClosedException
Thrown when the inbound sync stream closes before an expected event arrives.
CrdtSyncUnexpectedEventException<T extends CrdtSyncStreamEvent>
Thrown when the inbound sync stream delivers an event of the wrong type.
DuplicateNodeException
Exception thrown when a duplicate node is detected.
OverflowException
Exception thrown when the timestamp counter overflows.
SyncTablesHashMismatchException
Thrown when the sync tables hash sent by a peer does not match locally.