SqlRunnerStorage
Stores cluster runner registration and shard ownership in SQL.
The SQL-backed RunnerStorage records runners, health flags, machine ids, and shard locks so multiple processes can coordinate which runner owns each shard. This module creates the required runner and lock tables, supports an optional table prefix, uses advisory locks for PostgreSQL and MySQL when enabled, and provides constructors and layers for the storage service.
Constructors
Layers
Layer that provides SQL-backed RunnerStorage using the default table prefix.
Signature
declare const layer: Layer.Layer<
RunnerStorage.RunnerStorage,
SqlError,
SqlClient.SqlClient | ShardingConfig.ShardingConfig
>;Layer that provides SQL-backed RunnerStorage using a custom table prefix.
Signature
declare function layerWith(options: {
readonly prefix?: string;
}): Layer<RunnerStorage, SqlError, ShardingConfig | SqlClient>;
Creates a SQL-backed
RunnerStorageimplementation for registered runners and shard locks, using the configured table prefix and advisory locks where supported and enabled.When to use
Use to create a SQL-backed
RunnerStoragevalue directly when building custom service or layer composition around the storage implementation.Details
When
prefixis omitted,makeuses theclusterprefix, creatingcluster_runnersandcluster_locks. PostgreSQL and MySQL use advisory locks unlessShardingConfig.shardLockDisableAdvisoryis enabled; other dialects use rows in the locks table.Gotchas
Changing
prefixchanges both generated table names, so runners using different prefixes do not share registrations or shard locks.See
layerfor the default SQL-backed storage layerlayerWithfor a SQL-backed storage layer with a custom table prefix