Crate entidb_sync_engine

Crate entidb_sync_engine 

Source
Expand description

§EntiDB Sync Engine

Sync state machine and engine for EntiDB.

This crate provides:

  • Sync state machine (idle → pulling → pushing → synced)
  • Cursor management
  • Conflict detection and resolution
  • Retry with exponential backoff
  • HTTP transport abstraction
  • Database-backed sync applier

§Architecture

The sync engine implements a pull-then-push synchronization model:

  1. Pull remote changes first (server is authoritative)
  2. Apply remote changes locally
  3. Push local changes to server

The sync server uses the same EntiDB core as clients, ensuring consistent storage semantics everywhere.

§Key Invariants

  • Server is authoritative
  • Pull always happens before push
  • Operations are idempotent
  • Sync operations are atomic per batch
  • Server uses EntiDB for persistence (no external database)

Structs§

DatabaseApplier
A sync applier backed by an EntiDB database.
HttpTransport
HTTP-based sync transport.
LoopbackClient
A loopback HTTP client that routes requests directly to a sync server.
MemorySyncApplier
An in-memory sync applier for testing.
MockTransport
A mock transport for testing.
RetryConfig
Configuration for retry behavior.
SyncConfig
Configuration for sync operations.
SyncCycleResult
Result of a sync cycle.
SyncEngine
The sync engine manages synchronization with a remote server.
SyncStats
Statistics about sync operations.

Enums§

SyncError
Errors that can occur during sync operations.
SyncRequest
Request types for sync operations.
SyncResponse
Response types for sync operations.
SyncState
The current state of the sync engine.

Traits§

CborDecode
Trait for CBOR decoding.
CborEncode
Trait for CBOR encoding.
HttpClient
HTTP client abstraction.
LoopbackServer
Trait for servers that can handle loopback requests.
SyncApplier
Callback for applying remote operations to the local database.
SyncTransport
A sync transport handles network communication with the sync server.

Type Aliases§

SyncResult
Result type for sync operations.