1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 10:49:28 +02:00

Add more AP stats to stats endpoint

It will help to understand if the federation correctly works or not
This commit is contained in:
Chocobozzz 2021-02-26 10:28:11 +01:00
parent cb2e36618c
commit 543442a3be
No known key found for this signature in database
GPG key ID: 583A612D890159BE
5 changed files with 137 additions and 19 deletions

View file

@ -1,10 +1,10 @@
import { AsyncQueue, queue } from 'async'
import { queue, QueueObject } from 'async'
import { logger } from '@server/helpers/logger'
import { SCHEDULER_INTERVALS_MS } from '@server/initializers/constants'
import { MActorDefault, MActorSignature } from '@server/types/models'
import { Activity } from '@shared/models'
import { processActivities } from './process'
import { StatsManager } from '../stat-manager'
import { processActivities } from './process'
type QueueParam = {
activities: Activity[]
@ -16,16 +16,12 @@ class InboxManager {
private static instance: InboxManager
private readonly inboxQueue: AsyncQueue<QueueParam>
private messagesProcessed = 0
private readonly inboxQueue: QueueObject<QueueParam>
private constructor () {
this.inboxQueue = queue<QueueParam, Error>((task, cb) => {
const options = { signatureActor: task.signatureActor, inboxActor: task.inboxActor }
this.messagesProcessed++
processActivities(task.activities, options)
.then(() => cb())
.catch(err => {
@ -35,7 +31,7 @@ class InboxManager {
})
setInterval(() => {
StatsManager.Instance.updateInboxStats(this.messagesProcessed, this.getActivityPubMessagesWaiting())
StatsManager.Instance.updateInboxWaiting(this.getActivityPubMessagesWaiting())
}, SCHEDULER_INTERVALS_MS.updateInboxStats)
}