Operations

Configuration reference

Check the options, types, and defaults for databases, backups, network access, device sync, and replication.

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.

OptionTypeDefaultDescription
driverSQLiteDriverrequiredSirannon opens connections through this driver.
hooksHookConfig-Sirannon calls these hooks around queries and connections. The server also calls them before subscriptions, snapshots, and device pushes.
metricsMetricsConfig-Sirannon reports query timing and row counts, database opens and closes, and delivered change events through these callbacks.
lifecycleLifecycleConfig-Sirannon applies these automatic-opening, idle-timeout, and open-database limits.
migrationsMigrationSource-Sirannon applies this migration set, or the set that this function returns, before it registers a writable database.
writerWorkerboolean | WriterWorkerOptions-Sirannon applies this writer-worker setting to every database in this registry.
cdcRetentionnumber-Sirannon applies this change-log retention in milliseconds to every database whose options leave cdcRetention out.
deviceCursorRetentionnumber-Sirannon applies this device-cursor retention in milliseconds to every database whose options leave deviceCursorRetention out.
maxChangesHeldForDevicenumber-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.

OptionTypeDefaultDescription
autoOpen.resolver(id: string) => { path, options? } | undefined-Sirannon calls this resolver to obtain a path for an unknown database ID.
idleTimeoutnumber0Sirannon 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.
maxOpennumber0Sirannon 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).

OptionTypeDefaultDescription
readOnlybooleanfalseSirannon opens the database read-only and refuses every write when true.
readPoolSizenumber4On 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.
connectionIdleTimeoutnumber30000Sirannon 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.
walModebooleantrueSirannon 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.
cdcPollIntervalnumber50Sirannon 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.
cdcRetentionnumber3600000Sirannon retains change history for this many milliseconds.
deviceCursorRetentionnumber2592000000Sirannon 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.
maxChangesHeldForDevicenumber0Sirannon deletes a device cursor when it retains more than this many changes from other writers for that cursor. With zero, Sirannon sets no limit.
writerWorkerboolean | WriterWorkerOptionsfalseSirannon executes writes on a dedicated thread when you set it. See writer worker.
backupsBackupCycleOptions-Sirannon captures the write-ahead log of this database to a destination on an interval. See continuous backups.
encryptionEncryptionOptions-Supply a function that returns 32 raw key bytes or { key, id }. See encryption.

WriterWorkerOptions

OptionTypeDefaultDescription
maxPendingWritesnumber1024Sirannon refuses new writes with WRITE_OVERLOADED when this many writes are in flight.
writeTimeoutMsnumber30000Sirannon 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.
maxRestartsnumber5Sirannon 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.

OptionTypeDefaultDescription
readonlybooleanfalseOpen the connection read-only.
encryption{ key: Uint8Array }-Supply the raw 32-byte key for this separate connection.
walModebooleantrueSirannon enables write-ahead logging when true.
synchronousSynchronousLevel'normal'SQLite applies this durability level.
walAutoCheckpointnumber-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.

OptionTypeDefaultDescription
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 modeWith 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.
executionTimeoutMsnumber-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.

OptionTypeDefaultDescription
maxRowsnumber-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.
maxBytesnumber-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

OptionTypeDefaultDescription
durability'off' | 'normal''off'SQLite applies this durability level during the load.
checkpointbooleantrueSirannon checkpoints after the load, except on a database with continuous backups, where Sirannon checkpoints in a turn of the backup cycle.
executionTimeoutMsnumber-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

OptionTypeDefaultDescription
rereadJitterMsnumber25Sirannon delays a reread by a random time below this many milliseconds.
maxTransactionChangesnumber10000Sirannon 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.

OptionTypeDefaultDescription
destinationBackupDestinationrequiredSirannon stores full copies, change pieces, and chain records through this destination.
intervalMsnumber60000Sirannon 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.
fullCopyIntervalMsnumber86400000Sirannon starts a new full copy after the chain reaches this age.
chainNamestring'sirannon-backup-chain'Sirannon stores the chain list under this name at the destination.
namePrefixstring'sirannon-backup'Sirannon prefixes each backup identifier with this value.
pieceBytesnumber16777216Sirannon uses this many bytes for each complete piece. For a streamed copy, set a multiple of 512.
fingerprintbooleantrueSirannon computes a SHA-256 digest when true.
stagingDirstringa directory beside the database fileSirannon stages captures in this directory before transfer.
maxUncapturedLogBytesnumberunboundedWhen 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.
replicationGroupBackupGroupSource-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.
pagesPerStepnumber256SQLite copies this many pages per step of a full copy.
restartLimitnumber3Sirannon fails a full copy with BACKUP_RESTARTED after this many restarts.
noProgressStepLimitnumber256Sirannon allows this many consecutive steps that copy no new page.
stallTimeoutMsnumber30000Sirannon fails with BACKUP_STALLED after this many milliseconds without a completed step.
destinationTimeoutMsnumber600000Sirannon 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.

OptionTypeDefaultDescription
destinationBackupDestinationrequiredSirannon stores and retrieves pieces through this destination.
namestringbackup-{ISO timestamp}.dbSirannon stores the pieces under this name.
chainIdstringA random identifier.Sirannon includes this chain identifier in the report.
pieceBytesnumber16777216Sirannon uses this many bytes for each complete piece.
fingerprintbooleantrueSirannon computes a SHA-256 digest over the copy.
pagesPerStepnumber256SQLite copies this many pages per step.
restartLimitnumber3Sirannon fails the copy with BACKUP_RESTARTED after this many restarts.
noProgressStepLimitnumber256Sirannon allows this many consecutive steps that copy no new page.
stallTimeoutMsnumber30000Sirannon fails after this many milliseconds without a completed copy step.
destinationTimeoutMsnumber600000Sirannon limits each destination call to this many milliseconds.
stagingDirstringthe host temporary directorySirannon 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.

OptionTypeDefaultDescription
cronstringrequiredSupply five fields for minute resolution, or six to add seconds at the front.
destDirstringrequiredSirannon writes scheduled copies into this directory.
maxFilesnumber5Sirannon retains this many matching copies, the newest by modification time. With zero or less, Sirannon deletes no copy.
timezonestringthe host zoneSirannon 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.
onBackupTimeoutMsnumber600000Sirannon 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.

OptionTypeDefaultDescription
destinationBackupDestinationrequiredSirannon retrieves backups and their records through this destination.
driverSQLiteDriverrequiredSirannon opens the restored database through this driver.
destPathstringrequiredSirannon writes the restored database to this path.
encryptionEncryptionOptions-Supply the key for the selected backup chain.
momentnumbernowSupply the target time in epoch milliseconds.
chainNamestring'sirannon-backup-chain'Sirannon reads the chain list under this name at the destination.
replaceExistingbooleanfalseSirannon replaces an existing target when true.
batchSizenumber16Sirannon replays this many change pieces between checkpoints, up to 4,096.
destinationTimeoutMsnumber600000Sirannon 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.

OptionTypeDefaultDescription
hoststring'127.0.0.1'The server binds to this address.
portnumber9876The server listens on this port.
corsboolean | CorsOptionsfalseThe server applies these cross-origin settings.
maxBodyBytesnumber1048576The server accepts bodies and messages up to this many bytes, which has to be a positive integer no larger than 4,294,967,295.
maxWebSocketBackpressureBytesnumberthe larger of 16777216 and maxBodyBytesThe server closes a connection when its outbound buffer exceeds this many bytes.
cdcRetentionMsnumber3600000The server retains changes for this many milliseconds, so a client can resume from a cursor only within that period.
deviceCursorRetentionMsnumber2592000000The 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.
maxChangesHeldForDevicenumber0The 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.
maxUnacknowledgedChangesnumber1000The server pauses delivery after this many unacknowledged changes.
authenticateAuthenticateHook<Identity>-The server calls this hook before database routes and WebSocket upgrades.
operationsOperationRegistry<Identity>-The server exposes these registered reads and writes for each database ID.
sharedOperationsDatabaseOperations<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.
acceptSqlbooleanfalseThe server accepts network SQL when true. It also accepts table subscriptions without an onBeforeSubscribe hook.
acceptEncryptionChangebooleanfalseThe 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.
acceptBackupRestorebooleanfalseThe server rebuilds a database from its backups over the network when true. createServer fails with INVALID_BACKUP_RESTORE when you set it without authenticate.
acceptDeviceSyncbooleanfalseThe server serves device sync when true. createServer fails with INVALID_DEVICE_SYNC when you set it without authenticate.
resolveExecutionTargetServerExecutionTargetResolver-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.
authorizeClusterStatusClusterStatusAuthorizer-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().

OptionTypeDefaultDescription
timeoutMsnumber30000The 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.

OptionTypeDefaultDescription
transport'websocket' | 'http''websocket'The client uses this transport.
headersRecord<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.
webSocketProtocolsstring | 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.
autoReconnectbooleantrueThe client reconnects after a recoverable WebSocket disconnect when true.
reconnectIntervalnumber1000The client starts a reconnection this many milliseconds after a disconnect.
requestTimeoutnumber30000The 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.

OptionTypeDefaultDescription
endpointsstring[]-The client requests coordinator routing metadata through these starter endpoints.
primarystring-The client sends static-mode writes to this primary endpoint.
replicasstring[]-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 modeThe client applies this read concern when selecting a node.

LoadAllOptions

OptionTypeDefaultDescription
batchSizenumber1000The 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.

OptionTypeDefaultDescription
urlstringrequiredSupply the server's base URL.
databaseIdstringrequiredSupply the database ID that the server serves.
tablesreadonly string[]requiredSupply at least one table for the pull subscription.
headersRecord<string, string>-The controller sends these headers on push, snapshot, and migration requests, and on Node or Bun pull upgrades.
webSocketProtocolsstring | string[]-The controller offers these subprotocols on the pull upgrade so that a browser device can send a credential.
batchSizenumber100The controller sends up to this many changes in each push, as an integer from 1 to 1000.
pushIntervalMsnumber1000The controller schedules pushes at this interval and uses it as the base retry delay.
ackIntervalMsnumber2000The device acknowledges applied changes at this interval in milliseconds.
maxPushRetryDelayMsnumber30000The controller limits push and pull retry delays to this many milliseconds.
requestTimeoutnumber30000The controller limits each HTTP request to this many milliseconds. With zero, the controller applies no deadline.
autoResyncbooleantrueThe controller downloads a snapshot automatically when the server requires a resync. Download the first snapshot of a new device explicitly.
snapshotRetryDelayMsnumber5000The controller retries a failed snapshot after this many milliseconds.
maxSnapshotRetryDelayMsnumber300000The controller limits snapshot retry delays to this many milliseconds.
snapshotPageSizenumber500The controller requests up to this many rows in each page, as an integer from 1 to 1000.
immediateAckAfterChangesnumberHalf the server's window, or 500.The device acknowledges once this many changes are outstanding.
resolverConflictResolver | ((table: string) => ConflictResolver)LWWResolverThe 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.

OptionTypeDefaultDescription
urlstringrequiredSupply the server's base URL.
databaseIdstringrequiredSupply the database ID to copy.
headersRecord<string, string>-The downloader sends these headers on manifest and page requests.
pageSizenumber500The downloader requests up to this many rows in each page, as an integer from 1 to 1000.
requestTimeoutMsnumber30000The 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.

OptionTypeDefaultDescription
nodeIdstringgenerated in static modeSupply a node identifier. In coordinator mode, supply a stable value that you keep across restarts.
topologyTopologyrequiredThe engine applies this topology, such as PrimaryReplicaTopology.
transportReplicationTransportrequiredThe engine sends peer traffic through this transport.
transportConfigTransportConfig{}Configure peer endpoints here in static mode, while the engine refuses endpoints in coordinator mode.
writeForwardingbooleanfalseA replica forwards writes to the primary when true.
defaultConflictResolverConflictResolverLWWResolverThe engine resolves conflicts through this resolver by default.
conflictResolversRecord<string, ConflictResolver>-The engine applies these table-specific resolvers.
batchSizenumber100The engine sends up to this many changes per replication batch.
batchIntervalMsnumber100The engine schedules outgoing batches at this interval in milliseconds.
maxClockDriftMsnumber60000The 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.
maxPendingBatchesnumber10The engine limits in-flight batches per peer to this count.
maxBatchChangesnumber1000The engine accepts up to this many changes per inbound batch.
ackTimeoutMsnumber5000The engine waits this many milliseconds for a batch acknowledgement.
initialSyncbooleantrueWith true, the engine requests a full snapshot when it joins a cluster.
syncBatchSizenumber10000The source sends up to this many rows per first-sync batch.
maxConcurrentSyncsnumber2The source serves up to this many simultaneous sync sessions.
maxSyncDurationMsnumber1800000The source abandons a sync after this many milliseconds.
maxSyncLagBeforeReadynumber100The engine reports itself ready only once its catch-up lag is at or below this count.
syncAckTimeoutMsnumber30000The engine waits this many milliseconds for each sync-batch acknowledgement.
catchUpDeadlineMsnumber600000A joining node spends at most this many milliseconds catching up before it marks itself ready, whatever its lag at that point.
resumeFromSeqbigint-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.
changeTrackerChangeTracker-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.
coordinatorCoordinatorModeConfig-The engine enables coordinator-backed authority and failover with this configuration.

CoordinatorModeConfig

OptionTypeDefaultDescription
clusterIdstringrequiredThe coordinator isolates this cluster under this identifier.
groupIdstringrequiredThis is the identifier of the replication group for one database.
endpointstring-The node publishes this application endpoint for client discovery.
replicationEndpointstring-The node publishes this peer address in its coordinator session.
votingDataBearingNodeIdsstring[]-The coordinator uses this voter set to create an unregistered group and calculate write concerns.
coordinatorClusterCoordinatorrequiredThe engine accesses cluster authority through this coordinator adapter.
sessionTtlMsnumber10000The 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.
maxReplicaLagMsnumber1000The 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.
controllerboolean | CoordinatorControllerConfigenabledThe engine enables the controller loop or applies the supplied controller configuration.
compatibilityCoordinatorCompatibilityMetadata-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.

OptionTypeDefaultDescription
hostsstring | string[]requiredSupply etcd endpoints with https unless allowInsecure is true.
keyPrefixstringrequiredThe coordinator stores this cluster's keys under this prefix.
credentialsetcd credentials-The coordinator authenticates through this root certificate, private key, and certificate chain.
authetcd auth-The coordinator authenticates through this username and password.
grpcOptionsRecord<string, unknown>-The coordinator forwards these options to the etcd gRPC channel.
dialTimeoutMsnumberThe etcd client's default.The coordinator limits connection setup to this many milliseconds.
defaultCallTimeoutMsnumber-The coordinator limits each call to this many milliseconds.
allowInsecurebooleanfalseThe 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.

OptionTypeDescription
endpointsstring[]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.
groupIdstringThe engine identifies the replication group during coordinator-mode handshakes.
primaryTermbigintThe engine supplies the current fencing term from coordinator state.
protocolVersionstringThe engine supplies this protocol version to peers.
encryptedbooleanThe engine supplies whether the database of this node is encrypted.
metadataRecord<string, unknown>The transport receives this application metadata.

GrpcReplicationOptions

GrpcReplicationTransport from @delali/sirannon-db/transport/grpc accepts these options.

OptionTypeDefaultDescription
hoststring'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.
portnumber0The transport listens on this port. With a value of zero, the operating system assigns an ephemeral port.
tlsCertstring-The transport loads this node's certificate from this path.
tlsKeystring-The transport loads this node's private key from this path.
tlsCaCertstring-The transport loads the certificate authority for peer verification from this path.
insecurebooleanfalseThe transport omits TLS when true. Use that mode only in local development.
forwardDeadlineMsnumber30000The transport limits a forwarded write to this many milliseconds, including the primary's wait for write concern.