kysely-replication
Version:
Replication-aware Kysely query execution
1 lines • 984 B
Source Map (JSON)
{"version":3,"sources":["../../src/strategy/random.ts"],"sourcesContent":["import type { ReplicaStrategy } from '../config.js'\n\nexport interface RandomReplicaStrategyOptions {\n\tonTransaction?: 'error' | 'warn' | 'allow'\n}\n\nexport class RandomReplicaStrategy implements ReplicaStrategy {\n\treadonly #options?: RandomReplicaStrategyOptions\n\n\tconstructor(options?: RandomReplicaStrategyOptions) {\n\t\tthis.#options = { ...options }\n\t}\n\n\tasync next(replicaCount: number): Promise<number> {\n\t\treturn Math.floor(Math.random() * replicaCount)\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,wBAAN,MAAuD;AAAA,EACpD;AAAA,EAET,YAAY,SAAwC;AACnD,SAAK,WAAW,EAAE,GAAG,QAAQ;AAAA,EAC9B;AAAA,EAEA,MAAM,KAAK,cAAuC;AACjD,WAAO,KAAK,MAAM,KAAK,OAAO,IAAI,YAAY;AAAA,EAC/C;AAAA,EAEA,IAAI,gBAAwD;AAC3D,WAAO,KAAK,UAAU;AAAA,EACvB;AACD;","names":[]}