Skip to main content

Crate wavesyncdb

Crate wavesyncdb 

Source
Expand description

§WaveSyncDB

Transparent peer-to-peer sync for SeaORM applications.

WaveSyncDB wraps a SeaORM DatabaseConnection via WaveSyncDb, intercepting write operations (INSERT, UPDATE, DELETE) and replicating them to peers over libp2p gossipsub. Conflicts are resolved automatically using Last-Write-Wins (LWW) with hybrid logical clocks.

§Quick start

use sea_orm::*;
use wavesyncdb::WaveSyncDbBuilder;

let db = WaveSyncDbBuilder::new("sqlite:./app.db?mode=rwc", "my-topic")
    .build()
    .await?;

// Auto-discover #[derive(SyncEntity)] entities
db.get_schema_registry(module_path!().split("::").next().unwrap())
    .sync()
    .await?;

// Standard SeaORM — sync is transparent
let task = task::ActiveModel { /* ... */ };
task.insert(&db).await?;

§Key types

Re-exports§

pub use connection::SchemaBuilder;
pub use connection::WaveSyncDb;
pub use connection::WaveSyncDbBuilder;
pub use messages::ChangeNotification;
pub use messages::NodeId;
pub use messages::SyncOperation;
pub use messages::WriteKind;
pub use registry::SyncEntityInfo;
pub use registry::TableMeta;
pub use registry::TableRegistry;
pub use sea_orm;

Modules§

conflict
Last-Write-Wins (LWW) conflict resolution.
connection
engine
P2P sync engine powered by libp2p.
messages
Core sync message types exchanged between nodes.
protocol
Full sync protocol types (work in progress).
registry
Table registry for tracking which tables participate in sync.
sync_log
Persistent operation log for sync history.

Macros§

register_sync_entity
Enter an element into the plugin registry corresponding to its type.