mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-10 22:17:44 +00:00
chill with the poll
This commit is contained in:
parent
09d5457436
commit
413b46631c
2 changed files with 5 additions and 4 deletions
|
@ -22,9 +22,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
checkInterval = 5 * time.Second // How long we wait in between checking for notifications, in seconds
|
rate = 0.1
|
||||||
pollDuration = 5 * time.Millisecond
|
|
||||||
rate = 0.1
|
|
||||||
|
|
||||||
postReplyNotificationTitleFormat = "%s to %s"
|
postReplyNotificationTitleFormat = "%s to %s"
|
||||||
commentReplyNotificationTitleFormat = "%s in %s"
|
commentReplyNotificationTitleFormat = "%s in %s"
|
||||||
|
@ -239,7 +237,7 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) {
|
||||||
// Only update delay on accounts we can actually check, otherwise it skews
|
// Only update delay on accounts we can actually check, otherwise it skews
|
||||||
// the numbers too much.
|
// the numbers too much.
|
||||||
if !newAccount {
|
if !newAccount {
|
||||||
latency := now.Sub(previousNextCheck) - checkInterval
|
latency := now.Sub(previousNextCheck) - domain.NotificationCheckInterval
|
||||||
_ = nc.statsd.Histogram("apollo.queue.delay", float64(latency.Milliseconds()), []string{}, rate)
|
_ = nc.statsd.Histogram("apollo.queue.delay", float64(latency.Milliseconds()), []string{}, rate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package worker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/DataDog/datadog-go/statsd"
|
"github.com/DataDog/datadog-go/statsd"
|
||||||
"github.com/adjust/rmq/v4"
|
"github.com/adjust/rmq/v4"
|
||||||
|
@ -10,6 +11,8 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const pollDuration = 100 * time.Millisecond
|
||||||
|
|
||||||
type NewWorkerFn func(context.Context, *logrus.Logger, *statsd.Client, *pgxpool.Pool, *redis.Client, rmq.Connection, int) Worker
|
type NewWorkerFn func(context.Context, *logrus.Logger, *statsd.Client, *pgxpool.Pool, *redis.Client, rmq.Connection, int) Worker
|
||||||
type Worker interface {
|
type Worker interface {
|
||||||
Start() error
|
Start() error
|
||||||
|
|
Loading…
Reference in a new issue