VSKI v0.6.6
Features
Section titled “Features”Replica Identification and Routing
Section titled “Replica Identification and Routing”Replicas can now identify themselves with a unique ID and public URL, enabling proper routing by load balancer and workflow executors.
How It Works
Section titled “How It Works”- Replica Identification: Replicas send
X-Replica-IdandX-Replica-Public-Urlheaders to master during sync - Master Tracking: Master stores known replicas in
_known_replicastable with their public URLs - Response Headers: Replicas include
X-Replica-Idheader in all response - Client SDK: Client automatically captures
X-Replica-Idfrom responses and includes it in subsequent request - Workflow Routing: Workers can specify
replicaIdwhen subscribing to workflows to route job to specific replicas
Incremental Sync
Section titled “Incremental Sync”Replicas now use SQLite changesets for incremental synchronization instead of full database downloads, dramatically reducing sync time and bandwidth.
How it Works
Section titled “How it Works”- Initial Sync: Fresh replicas download the full database from master
- Session Reset: After full download, replica resets master’s session to ensure clean changeset tracking
- Schema Comparison: Replicas compute and compare schema hashes with master before attempting incremental sync
- Schema Migration: If schemas differ, replica fetches master schema and applies migrations (CREATE TABLE, ALTER TABLE, indexes, triggers, views)
- Changeset Application: After schema sync, replicas apply changesets for data changes (INSERT, UPDATE, DELETE)
- Automatic Fallback: If replica has no replication state, it downloads full database
Schema Synchronization
Section titled “Schema Synchronization”When schema changes are detected (new collections, field changes, indexes), replicas automatically migrate their schema:
- Hash-Based Detection: Schema hashes are computed from
sqlite_master(tables, indexes, triggers, views) - Schema Fetch: Replica fetches full schema from master via
/api/replica/schema-sync - Diff Computation: Replica computes schema diff (new tables, altered tables, new/dropped indexes, triggers, views)
- Migration Application: Replica applies schema migrations:
CREATE TABLEfor new collectionsALTER TABLE ADD COLUMNfor new fields (columns are never deleted or renamed)CREATE INDEX,CREATE TRIGGER,CREATE VIEWfor new objectsDROP INDEX,DROP TRIGGER,DROP VIEWfor removed objects- Tables are never dropped on replica
Configuration
Section titled “Configuration”# Replica server configurationREPLICA_MODE=replicaREPLICA_ID=my-replica-001 # Unique identifier for this replicaPUBLIC_URL=https://replica.example.com # Public URL for routingMASTER_URL=https://master.example.comSYNC_INTERVAL=60New Admin Endpoints
Section titled “New Admin Endpoints”| Endpoint | Description |
|---|---|
GET /api/admin/known-replicas | List all known replicas that have synced with master |
GET /api/admin/known-replicas?with_public_url=true | Filter replicas by presence of public URL |
Client SDK
Section titled “Client SDK”// Health check endpointconst isHealthy = await client.health();
// Get list of known replicas from masterconst replicas = await client.replicas.listKnown();
// Filter by those with public URLsconst publicReplicas = await client.replicas.listKnown({ withPublicUrl: true });
// Client automatically captures replicaId from responsesconst records = await client.collection('posts').getList(1, 10);console.log(client.replicaId); // Set from X-Replica-Id header
// Route workflow to specific replicaawait client.workflow.start('my-workflow', { arg1: 'value' }, { replicaId: 'replica-001' });Web Dashboard
Section titled “Web Dashboard”- Connection modal displays known replicas with their IDs for allowing quick switching between master and replica servers
- Health check endpoint used for connectivity verification
New Environment Variables
Section titled “New Environment Variables”| Variable | Default | Description |
|---|---|---|
REPLICA_ID | (none) | Unique identifier for this replica instance |
PUBLIC_URL | (none) | Public URL for routing requests to this replica |
Technical Details
Section titled “Technical Details”New Replica API Endpoints
Section titled “New Replica API Endpoints”| Endpoint | Method | Description |
|---|---|---|
/api/replica/schema-sync | GET | Get full schema from master for migration (internal) |
/api/replica/reset-session | POST | Reset master’s SQLite session after full download (internal) |
Files Changed
Section titled “Files Changed”internal/replica/syncer.go- Incremental sync logic, schema comparison and migration, hash-based change detectioninternal/replica/session_manager.go- Session management,ResetSession()method, schema hash computation,GetFullSchema()internal/api/replica.go-ResetSessionendpoint,SchemaSyncendpoint, changeset generationinternal/config/config.go- AddedReplicaIDandPublicURLconfig fieldsinternal/replica/middleware.go- AddedX-Replica-IdtoReplicaStatusMiddlewareinternal/replica/types.go- AddedKnownReplicastructinternal/replica/registry.go- AddedUpsertKnownReplica,ListKnownReplicaswith filterinternal/db/db.go- Added_known_replicastable schemainternal/app/bootstrap.go- Passcfg.ReplicaIDto syncer and middlewareclient/src/client.ts- AddedreplicaIdproperty,health()method, capture from response headersclient/src/types.ts- AddedreplicaIdtoWorkflowOptionsclient/src/api/replicas.ts- New namespace for known replicas managementweb/lib/sdk.tsx- Use/healthendpoint for connectivity checkweb/components/layout/ConnectionBadge.tsx- Display known replicas in server list
Breaking Changes
Section titled “Breaking Changes”None
Migration
Section titled “Migration”No migration required. The _known_replicas table is created automatically on startup.