-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.js
More file actions
109 lines (109 loc) · 3.04 KB
/
client.js
File metadata and controls
109 lines (109 loc) · 3.04 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const bullmq_1 = require("bullmq");
const dotenv = __importStar(require("dotenv")); // see https://github.com/motdotla/dotenv#how-do-i-use-dotenv-with-import
const types_1 = require("./types");
dotenv.config();
// const client = createClient({
// url: process.env.REDIS_URL,
// });
if (!process.env.PORT)
throw new Error("redis env not defiend");
// video-prossing
// image-prossing
const queue = new bullmq_1.Queue(types_1.imageProcess, {
connection: {
host: process.env.HOST,
port: parseInt(process.env.PORT),
password: process.env.PASSWORD,
name: process.env.NAME,
},
});
const every = 1000 * 60 * 15;
const array = [];
for (let i = 0; i < 10; i++) {
array.push({
data: { qux: i, id: "id", width: 200, height: 200 },
name: "hls",
opts: {
removeOnComplete: true,
removeOnFail: true,
repeat: {
every: every,
limit: 5,
},
},
});
}
queue
.addBulk(array)
.then(() => {
return queue.count();
})
.then((data) => {
console.log(data);
queue.disconnect();
});
queue.on("error", (err) => {
console.log(err);
});
// queue
// .add(
// "hls",
// { qux: "jdsbjhbsdjbs sjhdbjhbsdjbjh", id: "id" },
// {
// removeOnComplete: true,
// removeOnFail: true,
// repeat: {
// every: every,
// limit: 5,
// },
// delay: 1000,
// }
// )
// .then(() => queue.disconnect());
// queue.on("error", (err) => {
// console.log(err);
// });
// client.on("error", (err) => console.log("Redis Client Error", err));
// client
// .connect()
// .then(async () => {
// await client.publish(
// "video-prossing",
// JSON.stringify({
// id: randomUUID(),
// key: randomUUID(),
// url: randomUUID(),
// })
// );
// })
// .finally(() => {
// client.disconnect();
// })
// .catch((e) => {
// console.log(e);
// });