Retry outbound reactions for up to a day
This commit is contained in:
parent
4a6b7968c1
commit
8670a4d864
25 changed files with 1444 additions and 473 deletions
23
ts/jobs/helpers/InMemoryQueues.ts
Normal file
23
ts/jobs/helpers/InMemoryQueues.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import PQueue from 'p-queue';
|
||||
|
||||
export class InMemoryQueues {
|
||||
private readonly queues = new Map<string, PQueue>();
|
||||
|
||||
get(key: string): PQueue {
|
||||
const existingQueue = this.queues.get(key);
|
||||
if (existingQueue) {
|
||||
return existingQueue;
|
||||
}
|
||||
|
||||
const newQueue = new PQueue({ concurrency: 1 });
|
||||
newQueue.once('idle', () => {
|
||||
this.queues.delete(key);
|
||||
});
|
||||
|
||||
this.queues.set(key, newQueue);
|
||||
return newQueue;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue