spb/market-atlas
Public
TypeScript 96.7%
SQL 1.6%
CSS 0.8%
JavaScript 0.5%
1/** Minimal async mutex: serializes critical sections (multi-row upserts) so Postgres never sees two overlapping lock orders. */2export class Mutex {3 private tail: Promise<void> = Promise.resolve();45 run<T>(fn: () => Promise<T>): Promise<T> {6 const next = this.tail.then(fn, fn);7 this.tail = next.then(8 () => undefined,9 () => undefined,10 );11 return next;12 }13}1415/** One writer at a time for each hot table family. */16export const barsMutex = new Mutex();17export const quotesMutex = new Mutex();18export const masterMutex = new Mutex(); // instruments, companies, symbol_aliases19