From 16eeaae3ad8eb21112088b7024ead34171a19a28 Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Mon, 31 Oct 2022 15:22:42 -0400 Subject: [PATCH] poll twice as much for jobs --- internal/worker/notifications.go | 15 +++------------ internal/worker/worker.go | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/internal/worker/notifications.go b/internal/worker/notifications.go index e4de5ea..0a4846f 100644 --- a/internal/worker/notifications.go +++ b/internal/worker/notifications.go @@ -119,17 +119,14 @@ func (nw *notificationsWorker) Stop() { type notificationsConsumer struct { *notificationsWorker - tag int - - apnsSandbox *apns2.Client - apnsProduction *apns2.Client + tag int + apns *apns2.Client } func NewNotificationsConsumer(nw *notificationsWorker, tag int) *notificationsConsumer { return ¬ificationsConsumer{ nw, tag, - apns2.NewTokenClient(nw.apns), apns2.NewTokenClient(nw.apns).Production(), } } @@ -321,14 +318,8 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) { for _, device := range devices { notification.DeviceToken = device.APNSToken - client := nc.apnsProduction - /* - if device.Sandbox { - client = nc.apnsSandbox - } - */ - res, err := client.PushWithContext(ctx, notification) + res, err := nc.apns.PushWithContext(ctx, notification) if err != nil { _ = nc.statsd.Incr("apns.notification.errors", []string{}, 1) nc.logger.Error("failed to send notification", diff --git a/internal/worker/worker.go b/internal/worker/worker.go index f7b31ac..40e01eb 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -11,7 +11,7 @@ import ( "go.uber.org/zap" ) -const pollDuration = 100 * time.Millisecond +const pollDuration = 50 * time.Millisecond type NewWorkerFn func(context.Context, *zap.Logger, *statsd.Client, *pgxpool.Pool, *redis.Client, rmq.Connection, int) Worker type Worker interface {