crdt_grpc_sync library

Classes

CrdtSync
Manages a bidirectional sync session between two Crdt nodes. Use CrdtSync.client for the initiator (connects to a remote server). Use CrdtSync.server for the responder (accepts incoming connections).
CrdtSyncClient
Auto-reconnecting client that syncs a Crdt with a remote peer via gRPC. Exposes methods connect(), disconnect() and dispose()
CrdtSyncConfig
Configuration for a CrdtSync sync session. Controls how changesets are built, validated, transformed, and reported.
CrdtSyncServer
Bundles a gRPC Server with its CrdtSyncService. Call shutdown to close all sessions then shut down server.
CrdtSyncService
gRPC service implementation for CrdtSync. Handles the unary Handshake RPC and the bidirectional Sync RPC.
CrdtSyncServiceConfig

Enums

CrdtRecordFormat
Target record format for the crdt implementation.
SocketState
Connection states for the sync client.

Functions

listen(Crdt crdt, int port, {CrdtSyncServiceConfig config = const CrdtSyncServiceConfig()}) Future<CrdtSyncServer>
Start a gRPC server that accepts CrdtSync connections. crdt is the local CRDT instance to sync with peers. port is the listening port (0 = OS-assigned).

Typedefs

ChangesetBuilder = FutureOr<CrdtChangeset> Function({String? exceptNodeId, Hlc? modifiedAfter, Hlc? modifiedOn, String? onlyNodeId, Iterable<String>? onlyTables})
Builds a changeset for sync. Customize to filter, transform, or encrypt.
ChangesetMapper = CrdtRecord Function(String table, CrdtRecord record)
Transforms records before encode (outgoing) or after decode (incoming).
ClientHandshakeDataBuilder = FutureOr<Object>? Function()
Builds custom metadata sent in the client handshake.
OnChangesetEvent = void Function(String nodeId, Map<String, int> recordCounts)
Reports sent or received changeset with record counts per table.
OnClientConnected = void Function(CrdtSync crdtSync, Object? customData)
Called on successful client init, customData is from handshake callback
OnClientConnecting = void Function(ServiceCall call)
Called when a new gRPC handshake request arrives.
OnConnected = void Function(String peerId, Object? customData)
Called when handshake completes successfully.
OnDisconnected = void Function(String peerId, int code, String reason)
Called when connection with peer is lost.
RecordValidator = FutureOr<bool> Function(String table, CrdtRecord record)
Validates incoming records before merge. Return false to reject.
ServerHandshakeDataBuilder = FutureOr<Object>? Function(String peerId, Object? peerData)
Builds custom metadata sent in the server handshake response.