kysely-replication
Version:
Replication-aware Kysely query execution
1 lines • 1.09 kB
Source Map (JSON)
{"version":3,"sources":["../../src/strategy/round-robin.ts"],"sourcesContent":["import type { ReplicaStrategy } from '../config.js'\n\nexport interface RoundRobinReplicaStrategyOptions {\n\tonTransaction?: 'error' | 'warn' | 'allow'\n}\n\nexport class RoundRobinReplicaStrategy implements ReplicaStrategy {\n\treadonly #options?: RoundRobinReplicaStrategyOptions\n\t#lastReplica = -1\n\n\tconstructor(options?: RoundRobinReplicaStrategyOptions) {\n\t\tthis.#options = { ...options }\n\t}\n\n\tasync next(replicaCount: number): Promise<number> {\n\t\tthis.#lastReplica = (this.#lastReplica + 1) % replicaCount\n\t\treturn this.#lastReplica\n\t}\n\n\tget onTransaction(): 'error' | 'warn' | 'allow' | undefined {\n\t\treturn this.#options?.onTransaction\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,IAAM,4BAAN,MAA2D;AAAA,EACxD;AAAA,EACT,eAAe;AAAA,EAEf,YAAY,SAA4C;AACvD,SAAK,WAAW,EAAE,GAAG,QAAQ;AAAA,EAC9B;AAAA,EAEA,MAAM,KAAK,cAAuC;AACjD,SAAK,gBAAgB,KAAK,eAAe,KAAK;AAC9C,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,IAAI,gBAAwD;AAC3D,WAAO,KAAK,UAAU;AAAA,EACvB;AACD;","names":[]}