-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.mjs
38 lines (31 loc) · 805 Bytes
/
example.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { createClient } from "redis";
import { Queue, handleTimeout } from "./dist/index.mjs";
import { setTimeout } from "timers/promises";
const redisClient = createClient({
socket: {
host: "127.0.0.1",
port: 6379,
},
});
await redisClient.connect();
await redisClient.flushAll();
handleTimeout({
redisClient,
});
const addFriendQueue = new Queue({
redisClient,
name: "addFriend",
process: async (data) => {
await setTimeout(2000);
return { done: "lol", data };
},
});
addFriendQueue.add({ someData: 1 }, { groupName: "1234" }).then((res) => {
console.log(res);
});
addFriendQueue.add({ someData: 2 }, { groupName: "1234" }).then((res) => {
console.log(res);
});
addFriendQueue.add({ someData: 3 }, { groupName: "1234" }).then((res) => {
console.log(res);
});