Operations

Configuration reference

Every option the registry, a database, the backup cycle, the server, the client, the device sync controller, and the replication engine accept, with its type and its default.

Table of Contents

This page lists every option Sirannon accepts, grouped by the object that takes it. The guides explain what each one is for; this page is where you check a name, a type, or a default without reading a guide first.

An option marked required has no default and the call fails without it. An option with a dash for its default is absent unless you set it, and the description says what Sirannon does in its absence.

Opening databases

SirannonOptions

Passed to new Sirannon(options). See getting started.

OptionTypeDefaultDescription
driverSQLiteDriverrequiredThe driver adapter for your runtime.
hooksHookConfig-Before and after hooks for queries, connections, and subscriptions.
metricsMetricsConfig-Callbacks for query timing, connection events, and change-capture activity.
lifecycleLifecycleConfig-Automatic opening, idle timeout, and a cap on databases open at once.
migrationsMigrationSource-A migration set, or a function returning one, applied to every writable database before it registers.
writerWorkerboolean | WriterWorkerOptions-The writer-worker setting every database this registry opens inherits.

LifecycleConfig

See hooks, metrics, and lifecycle.

OptionTypeDefaultDescription
autoOpen.resolver(id: string) => { path, options? } | undefined-Resolves an unknown identifier to a file path, which is how a tenant opens on first access.
idleTimeoutnumber0Milliseconds before an idle database closes. Zero disables the timer.
maxOpennumber0Databases open at once before the least recently used one closes. Zero leaves the count unbounded.

createTenantResolver builds a resolver from a basePath, an optional file extension, and defaultOptions applied to every tenant it opens.

DatabaseOptions

Passed to sirannon.open(id, path, options).

OptionTypeDefaultDescription
readOnlybooleanfalseOpen the database read-only, which refuses every write.
readPoolSizenumber4Read connections the pool holds, on a driver that supports several connections.
walModebooleantrueWhether to enable write-ahead logging.
synchronous'off' | 'normal' | 'full' | 'extra''normal'Writer durability through PRAGMA synchronous. A bulk load restores this level when it finishes.
cdcPollIntervalnumber50Milliseconds between change capture polls.
cdcRetentionnumber3600000Milliseconds change history stays available to replay.
writerWorkerboolean | WriterWorkerOptionsfalseRun writes on a dedicated thread. See writer worker.
backupsBackupCycleOptions-Capture this database's write-ahead log to a destination on an interval. See continuous backups.

WriterWorkerOptions

OptionTypeDefaultDescription
maxPendingWritesnumber1024Writes in flight before new writes are refused with WRITE_OVERLOADED.
writeTimeoutMsnumber30000Per-operation deadline in milliseconds. Zero disables it.
maxRestartsnumber5Respawns allowed after the worker crashes, before writes fail with WRITER_WORKER_FATAL.

OpenOptions

Passed to driver.open(path, options) and to ConnectionPool.create, which application code reaches only when it opens a connection outside a Sirannon registry.

OptionTypeDefaultDescription
readonlybooleanfalseOpen the connection read-only.
walModebooleantrueWhether to enable write-ahead logging.
synchronousSynchronousLevel'normal'Writer durability the connection runs at.
walAutoCheckpointnumber-Frames the log may reach before SQLite checkpoints it on its own. Zero turns that off, which a database capturing its own log needs, and sirannon.open sets it to zero for you whenever backups is present.

Running statements

QueryOptions

Passed per call to query, execute, executeBatch, and a registered operation.

OptionTypeDefaultDescription
readConcern{ level: 'local' | 'majority' | 'linearizable' }-How current the read must be. Coordinator mode enforces it and static mode ignores it.
writeConcern{ level, timeoutMs? }a local commit in static mode, 'majority' in coordinator modeHow many nodes must acknowledge the write. timeoutMs defaults to 5,000.

BulkLoadOptions

OptionTypeDefaultDescription
durability'off' | 'normal''off'Durability in force while the load runs.
checkpointbooleantrueWhether the load ends with a checkpoint. A database opened with backups runs none whatever you set.

LiveQueryOptions

OptionTypeDefaultDescription
rereadJitterMsnumber25Upper bound on the random delay before a second read starts.
maxTransactionChangesnumber10000Buffered changes in one transaction before the query reads a second time.

Both options reach a local db.live only, because a remote subscription sends no options and the server opens the query with these defaults. UseLiveQueryOptions in the React entry adds enabled, which holds a query closed while it is false.

Backups

BackupCycleOptions

Passed as backups in DatabaseOptions. See continuous backups.

OptionTypeDefaultDescription
destinationBackupDestinationrequiredWhere the full copy, the change pieces, and the chain records go.
intervalMsnumber60000Milliseconds between captures. Zero means the cycle takes a turn only when you call captureBackupChanges.
fullCopyIntervalMsnumber86400000Milliseconds a chain runs before a fresh full copy starts a new one.
chainNamestring'sirannon-backup-chain'Name the destination stores the list of chains under.
namePrefixstring'sirannon-backup'What each backup is named after at the destination.
pieceBytesnumber16777216Bytes one whole piece holds. A streamed copy needs a multiple of 512.
fingerprintbooleantrueWhether each backup records a SHA-256 of what it wrote.
stagingDirstringa directory beside the database fileWhere a capture waits before it goes out.
maxUncapturedLogBytesnumberunboundedBytes the write-ahead log may reach across turns that capture nothing.
replicationGroupBackupGroupSource-Where this node reads its group's membership. See backups in a replication group.
preferredNode'replica' | 'primary' | { nodeId }'replica'Which node of that group takes the backups.
pagesPerStepnumber256Pages SQLite moves in one step of the full copy.
restartLimitnumber3Restarts the full copy absorbs before it fails with BACKUP_RESTARTED.
noProgressStepLimitnumber256Steps the copy may take without reaching a page it had not already copied.
stallTimeoutMsnumber30000Milliseconds the copy may move no pages before it fails with BACKUP_STALLED.
destinationTimeoutMsnumber600000Milliseconds one call to the destination may take. Zero leaves the calls unbounded.
onRun(report: BackupRunReport) => void-Called with the report of every backup the cycle finishes.
onProgress(progress: BackupProgress) => void-Called at step resolution while a turn proceeds.
onSkip(skip: BackupSkip) => void-Called with every turn the cycle passed over, and what it passed it over for.
onError(error: Error) => void-Called when a capture, a transfer, or a checkpoint fails. Set it.

BackupToDestinationOptions

Passed to db.backupTo(options). See backup destinations.

OptionTypeDefaultDescription
destinationBackupDestinationrequiredWhere the pieces go and where a restore reads them from.
namestringbackup-{ISO timestamp}.dbName the pieces are stored under.
chainIdstringan identifier the run mintsThe chain this copy begins.
pieceBytesnumber16777216Bytes one whole piece holds.
fingerprintbooleantrueWhether the run folds a SHA-256 over what it wrote.
pagesPerStepnumber256Pages SQLite moves in one step.
restartLimitnumber3Restarts the copy absorbs before it fails.
noProgressStepLimitnumber256Steps the copy may take without reaching a new page.
stallTimeoutMsnumber30000Milliseconds the copy may move no pages.
destinationTimeoutMsnumber600000Milliseconds one call to the destination may take.
stagingDirstringthe host temporary directoryDirectory the staged route writes its local file in.
onProgress(progress: BackupProgress) => void-Called during the copy and once per piece during the transfer.

BackupScheduleOptions

Passed to db.scheduleBackup(options). See backups.

OptionTypeDefaultDescription
cronstringrequiredFive fields for minute resolution, or six to add seconds at the front.
destDirstringrequiredDirectory each copy is written into.
maxFilesnumber5Copies matching backup-*.db to keep, by modification time.
timezonestringthe host zoneIANA name the cron expression is read in.
onBackup(report: BackupFileReport) => void | Promise<void>-Called after every finished copy, before the older files are cleared.
onBackupTimeoutMsnumber600000Milliseconds Sirannon waits for onBackup. Zero leaves the wait unbounded.
onError(error: Error) => void-Called with every failure. Set it.

BackupRestoreOptions

Passed to restoreBackup(options) from @delali/sirannon-db/backup. See restoring a database.

OptionTypeDefaultDescription
destinationBackupDestinationrequiredWhere the backups and their records are stored.
driverSQLiteDriverrequiredDriver the restore opens the rebuilt database through.
destPathstringrequiredPath the rebuilt database is written to.
momentnumbernowEpoch milliseconds you want back.
chainNamestring'sirannon-backup-chain'Name the list of chains is stored under.
replaceExistingbooleanfalseWhether to replace a database already at that path.
batchSizenumber16Change pieces replayed between one checkpoint and the next, up to 4,096.
destinationTimeoutMsnumber600000Milliseconds one call to the destination may take.
onProgress(progress: BackupRestoreProgress) => void-Called after every piece the restore fetches.

Serving over the network

ServerOptions

Passed to createServer(sirannon, options). See server.

OptionTypeDefaultDescription
hoststring'127.0.0.1'Bind address.
portnumber9876Listen port.
corsboolean | CorsOptionsfalseCross-origin configuration.
maxBodyBytesnumber1048576Largest HTTP body and WebSocket message, as a positive integer no larger than 4,294,967,295.
maxWebSocketBackpressureBytesnumberthe larger of 16777216 and maxBodyBytesBytes buffered per connection before the server closes it.
cdcRetentionMsnumber3600000Milliseconds change events stay available, which bounds how far back sinceSeq resumes.
deviceCursorRetentionMsnumber2592000000Milliseconds an idle device cursor lasts, 30 days by default.
maxUnacknowledgedChangesnumber1000How far a device may run past its acknowledged sequence before delivery pauses.
authenticateAuthenticateHook<Identity>-Runs before every database route and WebSocket upgrade.
operationsOperationRegistry<Identity>-Reads and writes this server serves by name, keyed by database identifier.
acceptSqlbooleanfalseWhether the server accepts SQL statements over the network.
acceptBackupRestorebooleanfalseWhether the server rebuilds a database from its backups over the network. A server that sets it without authenticate refuses to start, with INVALID_BACKUP_RESTORE.
resolveExecutionTargetServerExecutionTargetResolver-Resolves the target each database runs against, which is how replication enforces authority.
getReplicationStatus() => ReplicationStatusInfo | null-Feeds GET /health/ready with replication state.
getClusterStatus(databaseId: string) => ClusterStatusInfo | null-Feeds GET /db/{id}/cluster with routing metadata.
authorizeClusterStatusClusterStatusAuthorizer-Your check for whether a request may read cluster status, which names every node address.

ClientOptions

Passed to new SirannonClient(url, options). See client SDK.

OptionTypeDefaultDescription
transport'websocket' | 'http''websocket'Transport the client uses.
headersRecord<string, string>-Headers on HTTP requests, and on the WebSocket upgrade under Node and Bun. A browser client that sets it without webSocketProtocols on the WebSocket transport fails with INVALID_ARGUMENT.
webSocketProtocolsstring | string[]-Subprotocols offered during the upgrade, which is how a browser sends a credential. The client offers sirannon.v1 ahead of them.
autoReconnectbooleantrueWhether to reconnect after a WebSocket disconnect.
reconnectIntervalnumber1000Reconnect delay in milliseconds.
requestTimeoutnumber30000Per-request timeout in milliseconds on the WebSocket transport. Zero waits indefinitely.

TopologyAwareClientOptions

Accepted by TopologyAwareClient from @delali/sirannon-db/client/topology, alongside every ClientOptions field. SirannonClient refuses each of these with INVALID_ARGUMENT. See topology-aware routing.

OptionTypeDefaultDescription
endpointsstring[]-Starter list that coordinator mode queries for routing metadata.
primarystring-Primary endpoint used directly in static mode.
replicasstring[]-Replica endpoints used directly in static mode.
readPreference'primary' | 'replica' | 'nearest''primary'Which node serves a read.
discovery'static' | 'coordinator''static'Whether routing comes from your configuration or from GET /db/{id}/cluster.
readConcern'local' | 'majority' | 'linearizable''majority' in coordinator modeClient-wide read concern applied to node selection.

LoadAllOptions

OptionTypeDefaultDescription
batchSizenumber1000Rows per request. Each batch has to fit under the server's maxBodyBytes.
durability'off' | 'normal''off'Durability in force on the server while each batch loads.

Device sync

SyncControllerOptions

Passed to new SyncController(db, options). See device sync.

OptionTypeDefaultDescription
urlstringrequiredBase URL of the server.
databaseIdstringrequiredDatabase to sync against, under the identifier the server opened it with.
tablesreadonly string[]requiredTables the device syncs.
headersRecord<string, string>-Headers on push, snapshot, and migration requests, and on the pull upgrade under Node and Bun.
webSocketProtocolsstring | string[]-Subprotocols offered on the pull upgrade, which is how a browser device sends a credential.
batchSizenumber100Changes per push request.
pushIntervalMsnumber1000Push loop interval, which is also the base for retry backoff.
ackIntervalMsnumber2000Milliseconds between the device's acknowledgements of applied changes.
maxPushRetryDelayMsnumber30000Ceiling for push and pull retry backoff.
requestTimeoutnumber30000HTTP request timeout in milliseconds.
autoResyncbooleantrueWhether to download a snapshot on start, on a server resync signal, and after a failed download.
snapshotRetryDelayMsnumber5000First delay before retrying a failed snapshot.
maxSnapshotRetryDelayMsnumber300000Ceiling for snapshot retry backoff.
snapshotPageSizenumber500Rows per snapshot page.
immediateAckAfterChangesnumberhalf the server's windowOutstanding changes that trigger an immediate acknowledgement.
resolverConflictResolver | ((table: string) => ConflictResolver)LWWResolverConflict resolution for pulled changes.
onChange(event: ChangeEvent) => void-Called for each pulled change after it commits locally.
onStatusChange(status: SyncStatus) => void-Called with the device's status on a state change, a push, an applied pull batch, a required resync, and an error recorded or cleared.
onResyncRequired() => void-Called before a snapshot replaces local data.
onSnapshotProgress(progress: SnapshotProgress) => void-Table and row progress during a snapshot.
onSnapshotComplete(outcome: SnapshotOutcome) => void-Called once a snapshot load ends, reporting whether the local database is usable again.

SnapshotDownloadOptions

Accepted by downloadDatabaseSnapshot(db.deviceSync(), options), which copies a server database into a local one outside a SyncController. See device sync recovery.

OptionTypeDefaultDescription
urlstringrequiredBase URL of the server.
databaseIdstringrequiredDatabase to copy.
headersRecord<string, string>-Headers sent on the manifest and page requests.
pageSizenumber500Rows per snapshot page.
requestTimeoutMsnumber30000Per-request timeout in milliseconds.
onProgress(progress: SnapshotProgress) => void-Table and row progress during the copy.

Replication

ReplicationOptions

Passed to new ReplicationEngine(db, writerConn, options). See distributed replication.

OptionTypeDefaultDescription
nodeIdstringgenerated in static modeNode identifier. Coordinator mode needs a stable, persisted value.
topologyTopologyrequiredThe topology this node runs under, such as PrimaryReplicaTopology.
transportReplicationTransportrequiredTransport for node-to-node traffic.
transportConfigTransportConfig{}Peer endpoints and transport metadata.
writeForwardingbooleanfalseWhether a replica forwards writes to the primary.
defaultConflictResolverConflictResolverLWWResolverDefault conflict resolution.
conflictResolversRecord<string, ConflictResolver>-Per-table conflict resolution overrides.
batchSizenumber100Changes per replication batch.
batchIntervalMsnumber100Sender loop interval in milliseconds.
maxClockDriftMsnumber60000Largest clock gap between two nodes this node accepts before it rejects a batch.
maxPendingBatchesnumber10In-flight batches per peer before back-pressure.
maxBatchChangesnumber1000Changes accepted in one inbound batch.
ackTimeoutMsnumber5000Batch acknowledgement timeout in milliseconds.
initialSyncbooleantrueWhether to pull a full snapshot when joining a cluster.
syncBatchSizenumber10000Rows per batch during first sync.
maxConcurrentSyncsnumber2Simultaneous sync sessions the source serves.
maxSyncDurationMsnumber1800000Milliseconds before the source abandons a sync.
maxSyncLagBeforeReadynumber100Catch-up lag, in sequences, at which a node reaches ready.
syncAckTimeoutMsnumber30000Per-batch acknowledgement timeout during sync.
catchUpDeadlineMsnumber600000Milliseconds in catch-up before a node moves to ready.
resumeFromSeqbigint-Sequence to start replication from, for an out-of-band sync.
snapshotConnectionFactory() => Promise<SQLiteConnection>-Opens the read-only connections a source serves a sync from.
changeTrackerChangeTracker-Change-capture trigger manager, which first sync needs.
flowControl{ maxLagSeconds?, onLagExceeded? }-Replication lag monitoring callbacks.
onBeforeForwardedQuery(sql, params?) => void-Validation hook the primary runs before each forwarded statement.
coordinatorCoordinatorModeConfig-Turns on coordinator-backed authority and failover.

CoordinatorModeConfig

OptionTypeDefaultDescription
clusterIdstringrequiredCoordinator namespace for the cluster.
groupIdstringrequiredReplication group holding copies of one database.
endpointstring-Application endpoint advertised for client discovery.
votingDataBearingNodeIdsstring[]-Voter set used to create an unregistered group and to calculate write concerns.
coordinatorClusterCoordinatorrequiredCoordinator adapter, such as the etcd one.
sessionTtlMsnumber10000Node-session lease lifetime in milliseconds.
controllerboolean | CoordinatorControllerConfigenabledTurns the controller loop on, or configures its lease holder, lifetime, and tick interval.
compatibilityCoordinatorCompatibilityMetadata-Package, specification, and protocol versions checked before promotion.

CoordinatorControllerConfig accepts enabled, holderId, leaseTtlMs (10,000 milliseconds by default), and tickIntervalMs (1,000 milliseconds by default).

EtcdClusterCoordinatorOptions

Accepted by createEtcdCoordinator from @delali/sirannon-db/replication/coordinator/etcd.

OptionTypeDefaultDescription
hostsstring | string[]requiredetcd endpoints. Each has to use https unless you set allowInsecure.
keyPrefixstringrequiredKey namespace this cluster writes under.
credentialsetcd credentials-Root certificate, private key, and certificate chain for mutual TLS.
authetcd auth-Username and password authentication.
grpcOptionsRecord<string, unknown>-Options passed through to the etcd gRPC channel.
dialTimeoutMsnumberthe etcd client's own defaultConnection timeout in milliseconds.
defaultCallTimeoutMsnumber-Deadline applied to each coordinator call, in milliseconds.
allowInsecurebooleanfalseAllows plain http endpoints, so keep it to tests.
onWatcherError(error: Error) => void-Called when a coordinator watcher fails.

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[]Peer addresses replication connections are made to.
localRole'primary' | 'replica'Local topology role.
groupIdstringReplication group named in coordinator-mode handshakes.
primaryTermbigintCurrent fencing term, taken from coordinator state.
protocolVersionstringReplication protocol version advertised to peers.
metadataRecord<string, unknown>Custom transport metadata.

GrpcReplicationOptions

Accepted by GrpcReplicationTransport from @delali/sirannon-db/transport/grpc.

OptionTypeDefaultDescription
hoststring'0.0.0.0'Address this node listens on for replication traffic.
portnumber0Listen port. Zero takes an ephemeral one.
tlsCertstring-Path to this node's certificate.
tlsKeystring-Path to this node's private key.
tlsCaCertstring-Path to the certificate authority that signs every peer.
insecurebooleanfalseRuns without TLS, so keep it to local development.
forwardDeadlineMsnumber30000Deadline in milliseconds for a write forwarded to the primary.