Check each option against the object that accepts it. The driver factories are in the driver reference, while the key loaders and the status of a key change are in encryption.
Supply every option whose default column says required. A dash in the default column means that the option has no default, in which case the description of the option contains what Sirannon does without it.
Opening databases
SirannonOptions
Pass these options to new Sirannon(options). See getting started.
| Option | Type | Default | Description |
|---|---|---|---|
driver | SQLiteDriver | required | Sirannon opens connections through this driver. |
hooks | HookConfig | - | Sirannon calls these hooks around queries and connections. The server also calls them before subscriptions, snapshots, and device pushes. |
metrics | MetricsConfig | - | Sirannon reports query timing and row counts, database opens and closes, and delivered change events through these callbacks. |
lifecycle | LifecycleConfig | - | Sirannon applies these automatic-opening, idle-timeout, and open-database limits. |
migrations | MigrationSource | - | Sirannon applies this migration set, or the set that this function returns, before it registers a writable database. |
writerWorker | boolean | WriterWorkerOptions | - | Sirannon applies this writer-worker setting to every database in this registry. |
cdcRetention | number | - | Sirannon applies this change-log retention in milliseconds to every database whose options leave cdcRetention out. |
deviceCursorRetention | number | - | Sirannon applies this device-cursor retention in milliseconds to every database whose options leave deviceCursorRetention out. |
maxChangesHeldForDevice | number | - | Sirannon applies this limit to the changes that it retains for one device, on every database whose options leave maxChangesHeldForDevice out. |
LifecycleConfig
See hooks, metrics, and lifecycle.
| Option | Type | Default | Description |
|---|---|---|---|
autoOpen.resolver | (id: string) => { path, options? } | undefined | - | Sirannon calls this resolver to obtain a path for an unknown database ID. |
idleTimeout | number | 0 | Sirannon closes a database after this many milliseconds without a request. With zero, Sirannon closes no database for being idle. Sirannon closes the whole database at this timeout, while at connectionIdleTimeout it closes only the connections of the database. |
maxOpen | number | 0 | Sirannon evicts the least recently used database to enforce this limit. With zero, Sirannon sets no limit. |
createTenantResolver builds a resolver from a basePath, an optional file extension, and defaultOptions that it applies to every tenant that it opens.
DatabaseOptions
Pass these options to sirannon.open(id, path, options).
| Option | Type | Default | Description |
|---|---|---|---|
readOnly | boolean | false | Sirannon opens the database read-only and refuses every write when true. |
readPoolSize | number | 4 | On a driver with multiple connections, Sirannon opens up to this many readers for a database, and at least one. Sirannon opens the first reader of a writable database on its first read, and another reader whenever every open reader is busy at the start of a read, while it opens the first reader of a read-only database together with the database. |
connectionIdleTimeout | number | 30000 | Sirannon closes the readers of a database that goes this many milliseconds without a read, and it closes the writer as well once the database goes this long without a read or a write. Subscriptions and device connections remain open while every connection of the database is closed, because Sirannon opens a connection again on the next read, write, or change to the file. Sirannon leaves the writer open on a database with backups or writerWorker, an in-memory or URI path, a driver with a single connection, or an active replication engine, and while a backup copy or a key change is under way. It also leaves the first reader of a read-only database open. A setting that a PRAGMA statement changes on a connection lasts until Sirannon closes that connection. With zero, Sirannon leaves every connection open until the database closes. |
walMode | boolean | true | Sirannon enables write-ahead logging when true. |
synchronous | 'off' | 'normal' | 'full' | 'extra' | 'normal' | Sirannon configures writer durability through PRAGMA synchronous. Sirannon restores this level when a bulk load finishes. |
cdcPollInterval | number | 50 | Sirannon leaves at least this many milliseconds between the starts of two queries of the change log. While the database has a subscriber, Sirannon queries the log after each write through the database and after the driver reports a write to the file from another process. When the driver can't report those writes, Sirannon also queries the log once per interval. |
cdcRetention | number | 3600000 | Sirannon retains change history for this many milliseconds. |
deviceCursorRetention | number | 2592000000 | Sirannon retains changes for a device's cursor for up to this many milliseconds, which is 30 days by default. Sirannon deletes the cursor once the device's last acknowledgement, or the oldest change that Sirannon retains for the cursor, is older than this. The device then resyncs from a snapshot. |
maxChangesHeldForDevice | number | 0 | Sirannon deletes a device cursor when it retains more than this many changes from other writers for that cursor. With zero, Sirannon sets no limit. |
writerWorker | boolean | WriterWorkerOptions | false | Sirannon executes writes on a dedicated thread when you set it. See writer worker. |
backups | BackupCycleOptions | - | Sirannon captures the write-ahead log of this database to a destination on an interval. See continuous backups. |
encryption | EncryptionOptions | - | Supply a function that returns 32 raw key bytes or { key, id }. See encryption. |
WriterWorkerOptions
| Option | Type | Default | Description |
|---|---|---|---|
maxPendingWrites | number | 1024 | Sirannon refuses new writes with WRITE_OVERLOADED when this many writes are in flight. |
writeTimeoutMs | number | 30000 | Sirannon applies this per-operation deadline in milliseconds, although it interrupts no statement at the deadline. With zero, Sirannon applies no deadline. To stop a statement, set executionTimeoutMs on the call. |
maxRestarts | number | 5 | Sirannon allows this many worker restarts before it refuses writes with WRITER_WORKER_FATAL. |
OpenOptions
Pass these options to driver.open(path, options) and to ConnectionPool.create, which you call only when you open a connection outside a Sirannon registry.
| Option | Type | Default | Description |
|---|---|---|---|
readonly | boolean | false | Open the connection read-only. |
encryption | { key: Uint8Array } | - | Supply the raw 32-byte key for this separate connection. |
walMode | boolean | true | Sirannon enables write-ahead logging when true. |
synchronous | SynchronousLevel | 'normal' | SQLite applies this durability level. |
walAutoCheckpoint | number | - | SQLite checkpoints after this many log frames. With zero, SQLite makes no automatic checkpoint, which is the value that Sirannon sets when continuous backups are on. |
Running statements
QueryOptions
Pass these options to local methods that accept QueryOptions. Remote methods accept the concerns that the client guide describes.
| Option | Type | Default | Description |
|---|---|---|---|
readConcern | { level: 'local' | 'majority' | 'linearizable' } | - | The engine enforces this read concern in coordinator mode and ignores it in static mode. |
writeConcern | { level, timeoutMs? } | a local commit in static mode, 'majority' in coordinator mode | With this concern, you specify how many nodes have to acknowledge a write. timeoutMs defaults to 5,000. A replica that forwards the write sends this concern with it, so the primary answers the replica only once the nodes meet that concern. |
executionTimeoutMs | number | - | SQLite stops the statement after this many milliseconds of execution on the call's connection, after which Sirannon rolls back the call's transaction and fails the call with EXECUTION_TIMEOUT. Without it, SQLite executes each statement until the statement finishes. Sirannon accepts a whole number from 1 to 2,147,483,647 on a driver that reports executionTimeouts, while it refuses the option on every other driver with EXECUTION_TIMEOUT_UNSUPPORTED. See execution time limits. |
QueryWithColumnsOptions
Pass these options to db.queryWithColumns(sql, params, options), which also accepts readConcern and executionTimeoutMs from QueryOptions. See queries and transactions.
| Option | Type | Default | Description |
|---|---|---|---|
maxRows | number | - | queryWithColumns returns at most this many rows and sets truncated to 'rows' when the query has more. Sirannon accepts a whole number from 0 to 2^53-1 and refuses any other value with INVALID_READ_LIMIT. |
maxBytes | number | - | queryWithColumns stops before the first row that takes the total past this many bytes and sets truncated to 'bytes'. It counts 8 bytes for every value plus the UTF-8 length of each TEXT value and the length of each BLOB. Sirannon accepts the same range as for maxRows. |
BulkLoadOptions
| Option | Type | Default | Description |
|---|---|---|---|
durability | 'off' | 'normal' | 'off' | SQLite applies this durability level during the load. |
checkpoint | boolean | true | Sirannon checkpoints after the load, except on a database with continuous backups, where Sirannon checkpoints in a turn of the backup cycle. |
executionTimeoutMs | number | - | SQLite stops the load after this many milliseconds of execution, after which Sirannon rolls the load back and fails it with EXECUTION_TIMEOUT. Without it, SQLite executes the load until the load finishes. Sirannon accepts the same values as for QueryOptions. |
LiveQueryOptions
| Option | Type | Default | Description |
|---|---|---|---|
rereadJitterMs | number | 25 | Sirannon delays a reread by a random time below this many milliseconds. |
maxTransactionChanges | number | 10000 | Sirannon rereads the query when a transaction contains more than this many changes. |
onError | (error: Error) => void | - | Sirannon reports a listener's throw or rejected promise through this callback. |
Sirannon applies rereadJitterMs and maxTransactionChanges only to local queries, while the server applies its defaults to a remote query. You can pass onError to both local and remote queries. React's UseLiveQueryOptions adds enabled, with which the hook pauses the query while enabled is false.
Backups
BackupCycleOptions
Pass these options as backups in DatabaseOptions. See continuous backups.
| Option | Type | Default | Description |
|---|---|---|---|
destination | BackupDestination | required | Sirannon stores full copies, change pieces, and chain records through this destination. |
intervalMs | number | 60000 | Sirannon captures at this interval. With zero, Sirannon schedules no turn after the first turn of the cycle, so it then captures only when you request it. |
fullCopyIntervalMs | number | 86400000 | Sirannon starts a new full copy after the chain reaches this age. |
chainName | string | 'sirannon-backup-chain' | Sirannon stores the chain list under this name at the destination. |
namePrefix | string | 'sirannon-backup' | Sirannon prefixes each backup identifier with this value. |
pieceBytes | number | 16777216 | Sirannon uses this many bytes for each complete piece. For a streamed copy, set a multiple of 512. |
fingerprint | boolean | true | Sirannon computes a SHA-256 digest when true. |
stagingDir | string | a directory beside the database file | Sirannon stages captures in this directory before transfer. |
maxUncapturedLogBytes | number | unbounded | When Sirannon captures nothing in a turn while the write-ahead log contains at least this many bytes, it breaks the chain and checkpoints the log. |
replicationGroup | BackupGroupSource | - | Sirannon obtains this node's group membership through this source. See backups in a replication group. |
preferredNode | 'replica' | 'primary' | { nodeId } | 'replica' | Sirannon uses this preference to select an eligible backup node. |
pagesPerStep | number | 256 | SQLite copies this many pages per step of a full copy. |
restartLimit | number | 3 | Sirannon fails a full copy with BACKUP_RESTARTED after this many restarts. |
noProgressStepLimit | number | 256 | Sirannon allows this many consecutive steps that copy no new page. |
stallTimeoutMs | number | 30000 | Sirannon fails with BACKUP_STALLED after this many milliseconds without a completed step. |
destinationTimeoutMs | number | 600000 | Sirannon limits each destination call to this many milliseconds. With zero, Sirannon applies no deadline. |
onRun | (report: BackupRunReport) => void | - | Sirannon calls this function with each completed backup report. |
onProgress | (progress: BackupProgress) => void | - | Sirannon calls this function after each copy step and stored piece. |
onSkip | (skip: BackupSkip) => void | - | Sirannon reports each skipped turn and its reason through this callback. |
onError | (error: Error) => void | - | Sirannon reports capture, transfer, and checkpoint failures through this callback. Configure it. |
BackupToDestinationOptions
Pass these options to db.backupTo(options). See backup destinations.
| Option | Type | Default | Description |
|---|---|---|---|
destination | BackupDestination | required | Sirannon stores and retrieves pieces through this destination. |
name | string | backup-{ISO timestamp}.db | Sirannon stores the pieces under this name. |
chainId | string | A random identifier. | Sirannon includes this chain identifier in the report. |
pieceBytes | number | 16777216 | Sirannon uses this many bytes for each complete piece. |
fingerprint | boolean | true | Sirannon computes a SHA-256 digest over the copy. |
pagesPerStep | number | 256 | SQLite copies this many pages per step. |
restartLimit | number | 3 | Sirannon fails the copy with BACKUP_RESTARTED after this many restarts. |
noProgressStepLimit | number | 256 | Sirannon allows this many consecutive steps that copy no new page. |
stallTimeoutMs | number | 30000 | Sirannon fails after this many milliseconds without a completed copy step. |
destinationTimeoutMs | number | 600000 | Sirannon limits each destination call to this many milliseconds. |
stagingDir | string | the host temporary directory | Sirannon writes the staged local copy in this directory. |
onProgress | (progress: BackupProgress) => void | - | Sirannon reports copy steps and transferred pieces through this callback. |
BackupScheduleOptions
Pass these options to db.scheduleBackup(options). See backups.
| Option | Type | Default | Description |
|---|---|---|---|
cron | string | required | Supply five fields for minute resolution, or six to add seconds at the front. |
destDir | string | required | Sirannon writes scheduled copies into this directory. |
maxFiles | number | 5 | Sirannon retains this many matching copies, the newest by modification time. With zero or less, Sirannon deletes no copy. |
timezone | string | the host zone | Sirannon evaluates the expression in this IANA time zone. |
onBackup | (report: BackupFileReport) => void | Promise<void> | - | Sirannon calls this function after each completed copy, before it rotates older copies. |
onBackupTimeoutMs | number | 600000 | Sirannon gives onBackup this many milliseconds to finish. With zero, Sirannon applies no deadline. |
onError | (error: Error) => void | - | Sirannon reports each failure through this callback. Configure it. |
BackupRestoreOptions
Pass these options to restoreBackup(options) from @delali/sirannon-db/backup. See restoring a database.
| Option | Type | Default | Description |
|---|---|---|---|
destination | BackupDestination | required | Sirannon retrieves backups and their records through this destination. |
driver | SQLiteDriver | required | Sirannon opens the restored database through this driver. |
destPath | string | required | Sirannon writes the restored database to this path. |
encryption | EncryptionOptions | - | Supply the key for the selected backup chain. |
moment | number | now | Supply the target time in epoch milliseconds. |
chainName | string | 'sirannon-backup-chain' | Sirannon reads the chain list under this name at the destination. |
replaceExisting | boolean | false | Sirannon replaces an existing target when true. |
batchSize | number | 16 | Sirannon replays this many change pieces between checkpoints, up to 4,096. |
destinationTimeoutMs | number | 600000 | Sirannon limits each destination call to this many milliseconds. |
onProgress | (progress: BackupRestoreProgress) => void | - | Sirannon reports progress after each piece and batch. |
Serving over the network
ServerOptions
Pass these options to createServer(sirannon, options). See server.
| Option | Type | Default | Description |
|---|---|---|---|
host | string | '127.0.0.1' | The server binds to this address. |
port | number | 9876 | The server listens on this port. |
cors | boolean | CorsOptions | false | The server applies these cross-origin settings. |
maxBodyBytes | number | 1048576 | The server accepts bodies and messages up to this many bytes, which has to be a positive integer no larger than 4,294,967,295. |
maxWebSocketBackpressureBytes | number | the larger of 16777216 and maxBodyBytes | The server closes a connection when its outbound buffer exceeds this many bytes. |
cdcRetentionMs | number | 3600000 | The server retains changes for this many milliseconds, so a client can resume from a cursor only within that period. |
deviceCursorRetentionMs | number | 2592000000 | The server retains changes for a device's cursor for up to this many milliseconds before it deletes the cursor, which is 30 days by default. Sirannon applies an explicit deviceCursorRetention on a database in place of this setting. |
maxChangesHeldForDevice | number | 0 | The server deletes a cursor when it retains more than this many changes for that cursor. With zero, the server sets no limit. Sirannon applies an explicit option on a database in place of this setting. |
maxUnacknowledgedChanges | number | 1000 | The server pauses delivery after this many unacknowledged changes. |
authenticate | AuthenticateHook<Identity> | - | The server calls this hook before database routes and WebSocket upgrades. |
operations | OperationRegistry<Identity> | - | The server exposes these registered reads and writes for each database ID. |
sharedOperations | DatabaseOperations<Identity> | - | The server exposes these shared reads and writes on every database, including one opened after startup. The server serves a database-specific operation in place of a shared operation with the same identifier. |
acceptSql | boolean | false | The server accepts network SQL when true. It also accepts table subscriptions without an onBeforeSubscribe hook. |
acceptEncryptionChange | boolean | false | The server serves the encryption-change route when true, which requires authenticate and encryptionKeys. |
encryptionKeys | (databaseId: string, keyRef: string) => EncryptionKey | Promise<EncryptionKey> | - | The server resolves an operator's key reference through this function. |
acceptBackupRestore | boolean | false | The server rebuilds a database from its backups over the network when true. createServer fails with INVALID_BACKUP_RESTORE when you set it without authenticate. |
acceptDeviceSync | boolean | false | The server serves device sync when true. createServer fails with INVALID_DEVICE_SYNC when you set it without authenticate. |
resolveExecutionTarget | ServerExecutionTargetResolver | - | The server calls this resolver to obtain the execution target that enforces replication authority. |
getReplicationStatus | () => ReplicationStatusInfo | null | - | The server calls this function for replication state at GET /health/ready. |
getClusterStatus | (databaseId: string) => ClusterStatusInfo | null | - | The server calls this function for routing metadata at GET /db/{id}/cluster. |
authorizeClusterStatus | ClusterStatusAuthorizer | - | The server calls this function to authorise access to node addresses in cluster status. |
ServerCloseOptions
Pass these options to server.close(options) before you call sirannon.shutdown().
| Option | Type | Default | Description |
|---|---|---|---|
timeoutMs | number | 30000 | The server gives the requests in progress this many milliseconds to finish during shutdown. The server accepts whole numbers from 0 to 2,147,483,647. |
ClientOptions
Pass these options to new SirannonClient(url, options). See client SDK.
| Option | Type | Default | Description |
|---|---|---|---|
transport | 'websocket' | 'http' | 'websocket' | The client uses this transport. |
headers | Record<string, string> | - | The client sends these headers on HTTP requests and Node or Bun WebSocket upgrades. In a browser, the client refuses this option on the WebSocket transport without webSocketProtocols, with INVALID_ARGUMENT. |
webSocketProtocols | string | string[] | - | The client offers these subprotocols during the upgrade so that a browser can send a credential. The client offers sirannon.v1 ahead of them. |
autoReconnect | boolean | true | The client reconnects after a recoverable WebSocket disconnect when true. |
reconnectInterval | number | 1000 | The client starts a reconnection this many milliseconds after a disconnect. |
requestTimeout | number | 30000 | The client waits this many milliseconds for each WebSocket reply and for a checkpoint on either transport. With zero, the client waits without a deadline. |
TopologyAwareClientOptions
TopologyAwareClient from @delali/sirannon-db/client/topology accepts these options alongside every ClientOptions field. SirannonClient refuses each of these with INVALID_ARGUMENT. See topology-aware routing.
| Option | Type | Default | Description |
|---|---|---|---|
endpoints | string[] | - | The client requests coordinator routing metadata through these starter endpoints. |
primary | string | - | The client sends static-mode writes to this primary endpoint. |
replicas | string[] | - | The client uses these replica endpoints directly in static mode. |
readPreference | 'primary' | 'replica' | 'nearest' | 'primary' | The client selects a read node using this preference. |
discovery | 'static' | 'coordinator' | 'static' | The client obtains routes from configuration in static mode and from cluster metadata in coordinator mode. |
readConcern | 'local' | 'majority' | 'linearizable' | 'majority' in coordinator mode | The client applies this read concern when selecting a node. |
LoadAllOptions
| Option | Type | Default | Description |
|---|---|---|---|
batchSize | number | 1000 | The client sends up to this many rows per request. Each batch has to fit within the server's maxBodyBytes. |
durability | 'off' | 'normal' | 'off' | The server applies this durability level while loading each batch. |
Device sync
SyncControllerOptions
Pass these options to new SyncController(db, options). See device sync.
| Option | Type | Default | Description |
|---|---|---|---|
url | string | required | Supply the server's base URL. |
databaseId | string | required | Supply the database ID that the server serves. |
tables | readonly string[] | required | Supply at least one table for the pull subscription. |
headers | Record<string, string> | - | The controller sends these headers on push, snapshot, and migration requests, and on Node or Bun pull upgrades. |
webSocketProtocols | string | string[] | - | The controller offers these subprotocols on the pull upgrade so that a browser device can send a credential. |
batchSize | number | 100 | The controller sends up to this many changes in each push, as an integer from 1 to 1000. |
pushIntervalMs | number | 1000 | The controller schedules pushes at this interval and uses it as the base retry delay. |
ackIntervalMs | number | 2000 | The device acknowledges applied changes at this interval in milliseconds. |
maxPushRetryDelayMs | number | 30000 | The controller limits push and pull retry delays to this many milliseconds. |
requestTimeout | number | 30000 | The controller limits each HTTP request to this many milliseconds. With zero, the controller applies no deadline. |
autoResync | boolean | true | The controller downloads a snapshot automatically when the server requires a resync. Download the first snapshot of a new device explicitly. |
snapshotRetryDelayMs | number | 5000 | The controller retries a failed snapshot after this many milliseconds. |
maxSnapshotRetryDelayMs | number | 300000 | The controller limits snapshot retry delays to this many milliseconds. |
snapshotPageSize | number | 500 | The controller requests up to this many rows in each page, as an integer from 1 to 1000. |
immediateAckAfterChanges | number | Half the server's window, or 500. | The device acknowledges once this many changes are outstanding. |
resolver | ConflictResolver | ((table: string) => ConflictResolver) | LWWResolver | The controller resolves pulled changes through this resolver. |
onChange | (event: ChangeEvent) => void | - | The controller calls this function for each pulled change after the local commit. |
onStatusChange | (status: SyncStatus) => void | - | The controller reports status changes, pushes, applied pulls, resync requirements, and error changes through this callback. |
onResyncRequired | () => void | - | The controller calls this function when it marks a resync as required. Guard a manual download separately in your application. |
onSnapshotProgress | (progress: SnapshotProgress) => void | - | The controller reports table and row progress through this callback. |
onSnapshotComplete | (outcome: SnapshotOutcome) => void | - | The controller reports whether the local database is usable after a snapshot load through this callback. |
SnapshotDownloadOptions
downloadDatabaseSnapshot(db.deviceSync(), options) accepts these options and copies a server database into a local one outside a SyncController. See device sync recovery.
| Option | Type | Default | Description |
|---|---|---|---|
url | string | required | Supply the server's base URL. |
databaseId | string | required | Supply the database ID to copy. |
headers | Record<string, string> | - | The downloader sends these headers on manifest and page requests. |
pageSize | number | 500 | The downloader requests up to this many rows in each page, as an integer from 1 to 1000. |
requestTimeoutMs | number | 30000 | The downloader limits each request to this many milliseconds. |
onProgress | (progress: SnapshotProgress) => void | - | The downloader reports table and row progress through this callback. |
Replication
ReplicationOptions
Pass these options to new ReplicationEngine(db, writerConn, options). See distributed replication.
| Option | Type | Default | Description |
|---|---|---|---|
nodeId | string | generated in static mode | Supply a node identifier. In coordinator mode, supply a stable value that you keep across restarts. |
topology | Topology | required | The engine applies this topology, such as PrimaryReplicaTopology. |
transport | ReplicationTransport | required | The engine sends peer traffic through this transport. |
transportConfig | TransportConfig | {} | Configure peer endpoints here in static mode, while the engine refuses endpoints in coordinator mode. |
writeForwarding | boolean | false | A replica forwards writes to the primary when true. |
defaultConflictResolver | ConflictResolver | LWWResolver | The engine resolves conflicts through this resolver by default. |
conflictResolvers | Record<string, ConflictResolver> | - | The engine applies these table-specific resolvers. |
batchSize | number | 100 | The engine sends up to this many changes per replication batch. |
batchIntervalMs | number | 100 | The engine schedules outgoing batches at this interval in milliseconds. |
maxClockDriftMs | number | 60000 | The engine accepts an incoming batch whose newest timestamp is at most this many milliseconds ahead of the local clock. It accepts older batches whatever their age. |
maxPendingBatches | number | 10 | The engine limits in-flight batches per peer to this count. |
maxBatchChanges | number | 1000 | The engine accepts up to this many changes per inbound batch. |
ackTimeoutMs | number | 5000 | The engine waits this many milliseconds for a batch acknowledgement. |
initialSync | boolean | true | With true, the engine requests a full snapshot when it joins a cluster. |
syncBatchSize | number | 10000 | The source sends up to this many rows per first-sync batch. |
maxConcurrentSyncs | number | 2 | The source serves up to this many simultaneous sync sessions. |
maxSyncDurationMs | number | 1800000 | The source abandons a sync after this many milliseconds. |
maxSyncLagBeforeReady | number | 100 | The engine reports itself ready only once its catch-up lag is at or below this count. |
syncAckTimeoutMs | number | 30000 | The engine waits this many milliseconds for each sync-batch acknowledgement. |
catchUpDeadlineMs | number | 600000 | A joining node spends at most this many milliseconds catching up before it marks itself ready, whatever its lag at that point. |
resumeFromSeq | bigint | - | The engine starts replication from this sequence after an out-of-band sync. |
snapshotConnectionFactory | () => Promise<SQLiteConnection> | - | The source calls this factory for read-only snapshot connections. |
changeTracker | ChangeTracker | - | The source uses this change tracker during first sync. |
flowControl | { maxLagSeconds?, onLagExceeded? } | - | The engine reports replication lag through these callbacks. |
onBeforeForwardedQuery | (sql, params?) => void | - | The primary calls this validation hook before each forwarded statement. |
coordinator | CoordinatorModeConfig | - | The engine enables coordinator-backed authority and failover with this configuration. |
CoordinatorModeConfig
| Option | Type | Default | Description |
|---|---|---|---|
clusterId | string | required | The coordinator isolates this cluster under this identifier. |
groupId | string | required | This is the identifier of the replication group for one database. |
endpoint | string | - | The node publishes this application endpoint for client discovery. |
replicationEndpoint | string | - | The node publishes this peer address in its coordinator session. |
votingDataBearingNodeIds | string[] | - | The coordinator uses this voter set to create an unregistered group and calculate write concerns. |
coordinator | ClusterCoordinator | required | The engine accesses cluster authority through this coordinator adapter. |
sessionTtlMs | number | 10000 | The session lease of the node lasts this many milliseconds between renewals. After a controller takes the lease, it promotes a replica only if it finds no session of a primary within this period. Set it to the same value on every node. The engine refuses a value of 1,000 or less with a RangeError. |
maxReplicaLagMs | number | 1000 | The primary removes an in-sync replica that leaves a change unacknowledged for longer than this many milliseconds. Set it well below the write-concern timeout, because Sirannon completes a majority write only once every in-sync replica stores it. |
controller | boolean | CoordinatorControllerConfig | enabled | The engine enables the controller loop or applies the supplied controller configuration. |
compatibility | CoordinatorCompatibilityMetadata | - | The coordinator checks these package, specification, and protocol versions before promotion. |
CoordinatorControllerConfig accepts enabled, holderId, leaseTtlMs (10,000 milliseconds by default), and tickIntervalMs (1,000 milliseconds by default).
EtcdClusterCoordinatorOptions
createEtcdCoordinator from @delali/sirannon-db/replication/coordinator/etcd accepts these options.
| Option | Type | Default | Description |
|---|---|---|---|
hosts | string | string[] | required | Supply etcd endpoints with https unless allowInsecure is true. |
keyPrefix | string | required | The coordinator stores this cluster's keys under this prefix. |
credentials | etcd credentials | - | The coordinator authenticates through this root certificate, private key, and certificate chain. |
auth | etcd auth | - | The coordinator authenticates through this username and password. |
grpcOptions | Record<string, unknown> | - | The coordinator forwards these options to the etcd gRPC channel. |
dialTimeoutMs | number | The etcd client's default. | The coordinator limits connection setup to this many milliseconds. |
defaultCallTimeoutMs | number | - | The coordinator limits each call to this many milliseconds. |
allowInsecure | boolean | false | The coordinator accepts plain http endpoints when true. Restrict this setting to tests. |
onWatcherError | (error: Error) => void | - | The coordinator reports each watcher failure through this callback. It also reports each failed try to reopen a watch after etcd cancels it or after the client connects to a restored or new etcd cluster. |
TransportConfig
ReplicationEngine.start() fills in the role, the group, the term, and the protocol version. Set them yourself only when you use a ReplicationTransport without the engine.
| Option | Type | Description |
|---|---|---|
endpoints | string[] | The transport connects to these peers in static mode, while the engine refuses this list in coordinator mode. |
localRole | 'primary' | 'replica' | The engine supplies the local topology role. |
groupId | string | The engine identifies the replication group during coordinator-mode handshakes. |
primaryTerm | bigint | The engine supplies the current fencing term from coordinator state. |
protocolVersion | string | The engine supplies this protocol version to peers. |
encrypted | boolean | The engine supplies whether the database of this node is encrypted. |
metadata | Record<string, unknown> | The transport receives this application metadata. |
GrpcReplicationOptions
GrpcReplicationTransport from @delali/sirannon-db/transport/grpc accepts these options.
| Option | Type | Default | Description |
|---|---|---|---|
host | string | '0.0.0.0' | The transport listens for replication traffic on this address. For a host name, the transport binds every address that the name resolves to. The node refuses to start when the transport fails to bind one of those addresses. |
port | number | 0 | The transport listens on this port. With a value of zero, the operating system assigns an ephemeral port. |
tlsCert | string | - | The transport loads this node's certificate from this path. |
tlsKey | string | - | The transport loads this node's private key from this path. |
tlsCaCert | string | - | The transport loads the certificate authority for peer verification from this path. |
insecure | boolean | false | The transport omits TLS when true. Use that mode only in local development. |
forwardDeadlineMs | number | 30000 | The transport limits a forwarded write to this many milliseconds, including the primary's wait for write concern. |