mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-22 03:37:43 +00:00
poll twice as much for jobs
This commit is contained in:
parent
fbd3ff617a
commit
16eeaae3ad
2 changed files with 4 additions and 13 deletions
|
@ -119,17 +119,14 @@ 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 ¬ificationsConsumer{
|
return ¬ificationsConsumer{
|
||||||
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",
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue