poll twice as much for jobs

This commit is contained in:
Andre Medeiros 2022-10-31 15:22:42 -04:00
parent fbd3ff617a
commit 16eeaae3ad
2 changed files with 4 additions and 13 deletions

View file

@ -120,16 +120,13 @@ func (nw *notificationsWorker) Stop() {
type notificationsConsumer struct { type notificationsConsumer struct {
*notificationsWorker *notificationsWorker
tag int tag int
apns *apns2.Client
apnsSandbox *apns2.Client
apnsProduction *apns2.Client
} }
func NewNotificationsConsumer(nw *notificationsWorker, tag int) *notificationsConsumer { func NewNotificationsConsumer(nw *notificationsWorker, tag int) *notificationsConsumer {
return &notificationsConsumer{ return &notificationsConsumer{
nw, nw,
tag, tag,
apns2.NewTokenClient(nw.apns),
apns2.NewTokenClient(nw.apns).Production(), apns2.NewTokenClient(nw.apns).Production(),
} }
} }
@ -321,14 +318,8 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) {
for _, device := range devices { for _, device := range devices {
notification.DeviceToken = device.APNSToken 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 { if err != nil {
_ = nc.statsd.Incr("apns.notification.errors", []string{}, 1) _ = nc.statsd.Incr("apns.notification.errors", []string{}, 1)
nc.logger.Error("failed to send notification", nc.logger.Error("failed to send notification",

View file

@ -11,7 +11,7 @@ import (
"go.uber.org/zap" "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 NewWorkerFn func(context.Context, *zap.Logger, *statsd.Client, *pgxpool.Pool, *redis.Client, rmq.Connection, int) Worker
type Worker interface { type Worker interface {