Expand description
§EntiDB Sync Server
Reference HTTP sync server for EntiDB.
This crate provides:
- HTTP endpoints (handshake, pull, push)
- Server oplog persistence
- Authentication middleware (HMAC-SHA256 tokens)
- Conflict detection
§Architecture
The sync server uses the same EntiDB core as clients (no external database). It maintains:
- A server-side oplog of all operations
- Current cursor position for each device
- Authentication state
§Authentication
Authentication is optional but recommended for production:
ⓘ
use entidb_sync_server::{ServerConfig, AuthConfig, TokenValidator};
let secret = b"my-secure-secret-32-bytes-long!".to_vec();
let config = ServerConfig::default().with_auth(secret.clone());
// Create tokens for devices
let auth_config = AuthConfig::new(secret);
let validator = TokenValidator::new(auth_config);
let token = validator.create_token(device_id, db_id);§Protocol
The server implements pull-then-push synchronization:
- Client handshakes with device credentials (+ auth token if enabled)
- Client pulls changes since last cursor
- Client pushes local changes
- Server detects conflicts and applies policy
Structs§
- Auth
Config - Authentication configuration.
- Handler
Context - Context for request handling.
- Request
Handler - Handler for sync requests.
- Server
Config - Configuration for the sync server.
- Server
Oplog - Server-side operation log.
- Simple
Token Validator - Simple token validator that doesn’t check expiration. Useful for testing.
- Sync
Server - The sync server.
- Token
Validator - Token validator for incoming requests.
Enums§
- Server
Error - Errors that can occur in the sync server.
Type Aliases§
- Server
Result - Result type for server operations.