Refactoring
This commit is contained in:
parent
72fb23f4d5
commit
85d8e6f220
3 changed files with 225 additions and 192 deletions
|
@ -1,6 +1,6 @@
|
|||
import * as Deque from 'double-ended-queue';
|
||||
import Xev from 'xev';
|
||||
import { deliverQueue, inboxQueue } from '../queue';
|
||||
import { deliverQueue, inboxQueue, dbQueue, objectStorageQueue } from '../queue';
|
||||
|
||||
const ev = new Xev();
|
||||
|
||||
|
@ -18,6 +18,8 @@ export default function() {
|
|||
|
||||
let activeDeliverJobs = 0;
|
||||
let activeInboxJobs = 0;
|
||||
let activeDbJobs = 0;
|
||||
let activeObjectStorageJobs = 0;
|
||||
|
||||
deliverQueue.on('global:active', () => {
|
||||
activeDeliverJobs++;
|
||||
|
@ -27,9 +29,19 @@ export default function() {
|
|||
activeInboxJobs++;
|
||||
});
|
||||
|
||||
dbQueue.on('global:active', () => {
|
||||
activeDbJobs++;
|
||||
});
|
||||
|
||||
objectStorageQueue.on('global:active', () => {
|
||||
activeObjectStorageJobs++;
|
||||
});
|
||||
|
||||
async function tick() {
|
||||
const deliverJobCounts = await deliverQueue.getJobCounts();
|
||||
const inboxJobCounts = await inboxQueue.getJobCounts();
|
||||
const dbJobCounts = await dbQueue.getJobCounts();
|
||||
const objectStorageJobCounts = await objectStorageQueue.getJobCounts();
|
||||
|
||||
const stats = {
|
||||
deliver: {
|
||||
|
@ -43,7 +55,19 @@ export default function() {
|
|||
active: inboxJobCounts.active,
|
||||
waiting: inboxJobCounts.waiting,
|
||||
delayed: inboxJobCounts.delayed
|
||||
}
|
||||
},
|
||||
db: {
|
||||
activeSincePrevTick: activeDbJobs,
|
||||
active: dbJobCounts.active,
|
||||
waiting: dbJobCounts.waiting,
|
||||
delayed: dbJobCounts.delayed
|
||||
},
|
||||
objectStorage: {
|
||||
activeSincePrevTick: activeObjectStorageJobs,
|
||||
active: objectStorageJobCounts.active,
|
||||
waiting: objectStorageJobCounts.waiting,
|
||||
delayed: objectStorageJobCounts.delayed
|
||||
},
|
||||
};
|
||||
|
||||
ev.emit('queueStats', stats);
|
||||
|
@ -53,6 +77,8 @@ export default function() {
|
|||
|
||||
activeDeliverJobs = 0;
|
||||
activeInboxJobs = 0;
|
||||
activeDbJobs = 0;
|
||||
activeObjectStorageJobs = 0;
|
||||
}
|
||||
|
||||
tick();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue