dohertj2 dohertj2
  • Joined on 2026-02-20

ZB.MOM.WW.CBDDC.Core (1.0.3)

Published 2026-02-20 13:28:57 -05:00 by dohertj2

Installation

dotnet nuget add source --name dohertj2 --username your_username --password your_token 
dotnet add package --source dohertj2 --version 1.0.3 ZB.MOM.WW.CBDDC.Core

About this package

Core abstractions and logic for CBDDC, a lightweight P2P mesh database.

ZB.MOM.WW.CBDDC.Core

Core abstractions and logic for CBDDC, a peer-to-peer data synchronization middleware for .NET.

What Is CBDDC?

CBDDC is not a database � it's a sync layer that plugs into your existing data store (BLite) and enables automatic P2P replication across nodes in a mesh network. Your application reads and writes to its database as usual; CBDDC handles synchronization in the background.

What's In This Package

  • Interfaces: IDocumentStore, IOplogStore, IVectorClockService, IConflictResolver
  • Models: OplogEntry, Document, HlcTimestamp, VectorClock
  • Conflict Resolution: LastWriteWinsConflictResolver, RecursiveNodeMergeConflictResolver
  • Production Features: Document caching (LRU), offline queue, health monitoring, retry policies

Installation

# Pick a persistence provider
dotnet add package ZB.MOM.WW.CBDDC.Persistence # Embedded document DB

# Add networking
dotnet add package ZB.MOM.WW.CBDDC.Network

Quick Start

// 1. Define your DbContext
public class MyDbContext : CBDDCDocumentDbContext
{
    public DocumentCollection<string, User> Users { get; private set; }
    public MyDbContext(string path) : base(path) { }
}

// 2. Create your DocumentStore (the sync bridge)
public class MyDocumentStore : BLiteDocumentStore<MyDbContext>
{
    public MyDocumentStore(MyDbContext ctx, IPeerNodeConfigurationProvider cfg,
        IVectorClockService vc, ILogger<MyDocumentStore>? log = null)
        : base(ctx, cfg, vc, logger: log)
    {
        WatchCollection("Users", ctx.Users, u => u.Id);
    }

    protected override async Task ApplyContentToEntityAsync(
        string collection, string key, JsonElement content, CancellationToken ct)
    {
        var user = content.Deserialize<User>()!;
        user.Id = key;
        var existing = _context.Users.Find(u => u.Id == key).FirstOrDefault();
        if (existing != null) _context.Users.Update(user);
        else _context.Users.Insert(user);
        await _context.SaveChangesAsync(ct);
    }
    // ... implement other abstract methods
}

// 3. Register and use
builder.Services.AddCBDDCCore()
    .AddCBDDCBLite<MyDbContext, MyDocumentStore>(
        sp => new MyDbContext("data.blite"))
    .AddCBDDCNetwork<StaticPeerNodeConfigurationProvider>();

Key Concepts

Concept Description
CDC Change Data Capture � watches collections registered via WatchCollection()
Oplog Append-only hash-chained journal of changes per node
VectorClock Tracks causal ordering across the mesh
DocumentStore Your bridge between entities and the sync engine

Architecture

Your App ? DbContext.SaveChangesAsync()
               ?
               ? CDC Trigger
           DocumentStore.CreateOplogEntryAsync()
               ?
               ??? OplogEntry (hash-chained, HLC timestamped)
               ??? VectorClockService.Update()
                       ?
                       ?
               SyncOrchestrator (background)
               ??? Push to peers
               ??? Pull from peers ? ApplyBatchAsync
  • ZB.MOM.WW.CBDDC.Persistence � BLite embedded provider (.NET 10+)
  • ZB.MOM.WW.CBDDC.Network � P2P networking (UDP discovery, TCP sync, Gossip)

Documentation

License

MIT � see LICENSE

Dependencies

ID Version Target Framework
Microsoft.Extensions.Logging.Abstractions 8.0.0 net10.0
Details
NuGet
2026-02-20 13:28:57 -05:00
0
MrDevRobot
34 KiB
Assets (2)
Versions (1) View all
1.0.3 2026-02-20