mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-14 16:07:42 +00:00
each consumer gets their reddit client
This commit is contained in:
parent
710443830b
commit
5714fbaad7
1 changed files with 12 additions and 12 deletions
|
@ -39,7 +39,6 @@ type notificationsWorker struct {
|
||||||
db *pgxpool.Pool
|
db *pgxpool.Pool
|
||||||
redis *redis.Client
|
redis *redis.Client
|
||||||
queue rmq.Connection
|
queue rmq.Connection
|
||||||
reddit *reddit.Client
|
|
||||||
apns *token.Token
|
apns *token.Token
|
||||||
|
|
||||||
consumers int
|
consumers int
|
||||||
|
@ -49,14 +48,6 @@ type notificationsWorker struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNotificationsWorker(ctx context.Context, logger *zap.Logger, statsd *statsd.Client, db *pgxpool.Pool, redis *redis.Client, queue rmq.Connection, consumers int) Worker {
|
func NewNotificationsWorker(ctx context.Context, logger *zap.Logger, statsd *statsd.Client, db *pgxpool.Pool, redis *redis.Client, queue rmq.Connection, consumers int) Worker {
|
||||||
reddit := reddit.NewClient(
|
|
||||||
os.Getenv("REDDIT_CLIENT_ID"),
|
|
||||||
os.Getenv("REDDIT_CLIENT_SECRET"),
|
|
||||||
statsd,
|
|
||||||
redis,
|
|
||||||
consumers,
|
|
||||||
)
|
|
||||||
|
|
||||||
var apns *token.Token
|
var apns *token.Token
|
||||||
{
|
{
|
||||||
authKey, err := token.AuthKeyFromFile(os.Getenv("APPLE_KEY_PATH"))
|
authKey, err := token.AuthKeyFromFile(os.Getenv("APPLE_KEY_PATH"))
|
||||||
|
@ -78,7 +69,6 @@ func NewNotificationsWorker(ctx context.Context, logger *zap.Logger, statsd *sta
|
||||||
db,
|
db,
|
||||||
redis,
|
redis,
|
||||||
queue,
|
queue,
|
||||||
reddit,
|
|
||||||
apns,
|
apns,
|
||||||
consumers,
|
consumers,
|
||||||
|
|
||||||
|
@ -119,13 +109,23 @@ func (nw *notificationsWorker) Stop() {
|
||||||
|
|
||||||
type notificationsConsumer struct {
|
type notificationsConsumer struct {
|
||||||
*notificationsWorker
|
*notificationsWorker
|
||||||
|
reddit *reddit.Client
|
||||||
tag int
|
tag int
|
||||||
apns *apns2.Client
|
apns *apns2.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNotificationsConsumer(nw *notificationsWorker, tag int) *notificationsConsumer {
|
func NewNotificationsConsumer(nw *notificationsWorker, tag int) *notificationsConsumer {
|
||||||
|
reddit := reddit.NewClient(
|
||||||
|
os.Getenv("REDDIT_CLIENT_ID"),
|
||||||
|
os.Getenv("REDDIT_CLIENT_SECRET"),
|
||||||
|
nw.statsd,
|
||||||
|
nw.redis,
|
||||||
|
1,
|
||||||
|
)
|
||||||
|
|
||||||
return ¬ificationsConsumer{
|
return ¬ificationsConsumer{
|
||||||
nw,
|
nw,
|
||||||
|
reddit,
|
||||||
tag,
|
tag,
|
||||||
apns2.NewTokenClient(nw.apns).Production(),
|
apns2.NewTokenClient(nw.apns).Production(),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue