From 413b46631cbc799befaeb54886c1c7e6c64c05c0 Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Sat, 21 May 2022 13:17:04 -0400 Subject: [PATCH] chill with the poll --- internal/worker/notifications.go | 6 ++---- internal/worker/worker.go | 3 +++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/worker/notifications.go b/internal/worker/notifications.go index 06d5a7b..a1bca6f 100644 --- a/internal/worker/notifications.go +++ b/internal/worker/notifications.go @@ -22,9 +22,7 @@ import ( ) const ( - checkInterval = 5 * time.Second // How long we wait in between checking for notifications, in seconds - pollDuration = 5 * time.Millisecond - rate = 0.1 + rate = 0.1 postReplyNotificationTitleFormat = "%s to %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 // the numbers too much. if !newAccount { - latency := now.Sub(previousNextCheck) - checkInterval + latency := now.Sub(previousNextCheck) - domain.NotificationCheckInterval _ = nc.statsd.Histogram("apollo.queue.delay", float64(latency.Milliseconds()), []string{}, rate) } diff --git a/internal/worker/worker.go b/internal/worker/worker.go index d5ecd52..4dfd038 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -2,6 +2,7 @@ package worker import ( "context" + "time" "github.com/DataDog/datadog-go/statsd" "github.com/adjust/rmq/v4" @@ -10,6 +11,8 @@ import ( "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 Worker interface { Start() error