13 lines
429 B
TypeScript
13 lines
429 B
TypeScript
/** Only one local operation may wait for the PostgreSQL advisory lock.
|
|
* Otherwise queued requests could exhaust the pool needed by its current owner.
|
|
*/
|
|
export class FlowConfigurationQueue {
|
|
private tail: Promise<void> = Promise.resolve()
|
|
|
|
run<T>(operation: () => Promise<T>): Promise<T> {
|
|
const result = this.tail.then(operation)
|
|
this.tail = result.then(() => undefined, () => undefined)
|
|
return result
|
|
}
|
|
}
|