Storage Service Write: Improved conflict handling
This commit is contained in:
parent
866217a724
commit
27759233e4
10 changed files with 297 additions and 134 deletions
14
ts/util/JobQueue.ts
Normal file
14
ts/util/JobQueue.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
import PQueue from 'p-queue';
|
||||
import createTaskWithTimeout from '../textsecure/TaskWithTimeout';
|
||||
|
||||
function createJobQueue(label: string) {
|
||||
const jobQueue = new PQueue({ concurrency: 1 });
|
||||
|
||||
return (job: () => Promise<void>, id = '') => {
|
||||
const taskWithTimeout = createTaskWithTimeout(job, `${label} ${id}`);
|
||||
|
||||
return jobQueue.add(taskWithTimeout);
|
||||
};
|
||||
}
|
||||
|
||||
export const storageJobQueue = createJobQueue('storageService');
|
Loading…
Add table
Add a link
Reference in a new issue