-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathjobsManager.js
108 lines (88 loc) · 4.11 KB
/
jobsManager.js
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
var winston = require('./config/winston');
class JobsManager {
constructor(jobWorkerEnabled, geoService, botEvent, subscriptionNotifierQueued, botSubscriptionNotifier, updateLeadQueued) {
this.geoService = geoService;
this.botEvent = botEvent;
// this.subscriptionNotifier = subscriptionNotifier;
this.subscriptionNotifierQueued = subscriptionNotifierQueued;
this.botSubscriptionNotifier = botSubscriptionNotifier;
this.emailNotificatio = undefined;
this.activityArchiver = undefined;
this.whatsappWorker = undefined;
this.jobWorkerEnabled = jobWorkerEnabled;
// this.jobWorkerEnabled = false;
// if (process.env.JOB_WORKER_ENABLED=="true" || process.env.JOB_WORKER_ENABLED == true) {
// this.jobWorkerEnabled = true;
// }
// winston.info("JobsManager jobWorkerEnabled: "+ this.jobWorkerEnabled);
this.updateLeadQueued = updateLeadQueued;
}
listen() {
winston.info("JobsManager listener started");
if ( this.jobWorkerEnabled == true) {
return winston.info("JobsManager jobWorkerEnabled is enabled. Skipping listeners");
}
this.geoService.listen();
// this.botEvent.listen(); // disabled
// this.subscriptionNotifier.start();
this.subscriptionNotifierQueued.start();
this.updateLeadQueued.listen();
// this.botSubscriptionNotifier.start(); // disabled
}
listenEmailNotification(emailNotification) {
winston.info("JobsManager listenEmailNotification started");
if ( this.jobWorkerEnabled == true) {
return winston.info("JobsManager jobWorkerEnabled is enabled. Skipping listener for Email Notification");
}
this.emailNotification = emailNotification;
this.emailNotification.requestNotification.listen();
}
listenRoutingQueue(routingQueue) {
winston.info("JobsManager routingQueue started");
if ( this.jobWorkerEnabled == true) {
return winston.info("JobsManager jobWorkerEnabled is enabled. Skipping listener for routingQueue");
}
this.routingQueue = routingQueue;
this.routingQueue.listen();
}
listenScheduler(scheduler) {
winston.info("JobsManager scheduler started");
if ( this.jobWorkerEnabled == true) {
return winston.info("JobsManager jobWorkerEnabled is enabled. Skipping listener for scheduler");
}
this.scheduler = scheduler;
this.scheduler.taskRunner.start();
}
listenActivityArchiver(activityArchiver) {
winston.info("JobsManager listenActivityArchiver started");
if ( this.jobWorkerEnabled == true) {
return winston.info("JobsManager jobWorkerEnabled is enabled. Skipping listener for Activity Archiver");
}
this.activityArchiver = activityArchiver;
this.activityArchiver.listen();
}
listenWhatsappQueue(whatsappQueue) {
console.log("JobsManager listenWhatsappQueue started");
console.log("whatsappQueue is: ", whatsappQueue)
if ( this.jobWorkerEnabled == true) {
return winston.info("JobsManager jobWorkerEnabled is enabled. Skipping listener for Whatsapp Queue");
}
// this.whatsappWorker = whatsappQueue;
// this.whatsappQueue.listen(); // oppure codice
}
listenMultiWorker(multiWorkerQueue) {
console.log("JobsManager multiWorkerQueue started");
console.log("multiWorkerQueue is: ", multiWorkerQueue)
if (this.jobWorkerEnabled == true) {
return winston.info("JobsManager jobWorkerEnabled is enabled. Skipping listener for MultiWorker Queue");
}
}
// listenTrainingQueue(trainingQueue) {
// console.log("JobsManager listenTrainingQueue started");
// console.log("trainingQueue is: ", trainingQueue)
// if (this.jobWorkerEnabled == true) {
// return winston.info("JobsManager jobWorkerEnabled is enabled. Skipping listener for Training Queue");
// }
// }
}
module.exports = JobsManager;