@proca/queue
Version:
Proca server pushes actions through AMQP queues, to which you can plug in your microservice. This module provides few helpers to work with queues.
8 lines (7 loc) • 349 B
text/typescript
export const pause = (time?: number): Promise<any> => {
const min = (time && time > 2) ? time / 2 : 1;
const max = time ? time * 2 : 2; // wait between min time/2 and time*2
time = Math.floor(Math.random() * (max - min + 1) + min) * 1000;
console.log("wait", time);
return new Promise(resolve => setTimeout(() => resolve(time), time));
};