update scheduler

This commit is contained in:
Andre Medeiros 2022-11-01 13:14:33 -04:00
parent 646dc0dd34
commit 420499c9bb
2 changed files with 11 additions and 9 deletions

View file

@ -96,12 +96,14 @@ func SchedulerCmd(ctx context.Context) *cobra.Command {
s := gocron.NewScheduler(time.UTC)
s.SetMaxConcurrentJobs(8, gocron.WaitMode)
_, _ = s.Every(5).Seconds().SingletonMode().Do(func() { enqueueAccounts(ctx, logger, statsd, db, redis, luaSha, notifQueue) })
_, _ = s.Every(5).Second().Do(func() { enqueueSubreddits(ctx, logger, statsd, db, []rmq.Queue{subredditQueue, trendingQueue}) })
_, _ = s.Every(5).Second().Do(func() { enqueueUsers(ctx, logger, statsd, db, userQueue) })
_, _ = s.Every(5).Second().Do(func() { enqueueLiveActivities(ctx, logger, db, redis, luaSha, liveActivitiesQueue) })
_, _ = s.Every(5).Second().Do(func() { cleanQueues(logger, queue) })
_, _ = s.Every(5).Second().Do(func() { enqueueStuckAccounts(ctx, logger, statsd, db, stuckNotificationsQueue) })
eaj, _ := s.Every(5).Seconds().Do(func() { enqueueAccounts(ctx, logger, statsd, db, redis, luaSha, notifQueue) })
eaj.SingletonMode()
_, _ = s.Every(5).Seconds().Do(func() { enqueueSubreddits(ctx, logger, statsd, db, []rmq.Queue{subredditQueue, trendingQueue}) })
_, _ = s.Every(5).Seconds().Do(func() { enqueueUsers(ctx, logger, statsd, db, userQueue) })
_, _ = s.Every(5).Seconds().Do(func() { enqueueLiveActivities(ctx, logger, db, redis, luaSha, liveActivitiesQueue) })
_, _ = s.Every(5).Seconds().Do(func() { cleanQueues(logger, queue) })
_, _ = s.Every(5).Seconds().Do(func() { enqueueStuckAccounts(ctx, logger, statsd, db, stuckNotificationsQueue) })
_, _ = s.Every(1).Minute().Do(func() { reportStats(ctx, logger, statsd, db) })
//_, _ = s.Every(1).Minute().Do(func() { pruneAccounts(ctx, logger, db) })
//_, _ = s.Every(1).Minute().Do(func() { pruneDevices(ctx, logger, db) })

View file

@ -86,12 +86,12 @@ func (p *postgresAccountRepository) CreateOrUpdate(ctx context.Context, acc *dom
query := `
INSERT INTO accounts (username, reddit_account_id, access_token, refresh_token, token_expires_at,
last_message_id, next_notification_check_at, next_stuck_notification_check_at, is_deleted)
VALUES ($1, $2, $3, $4, $5, '', NOW(), NOW(), false)
VALUES ($1, $2, $3, $4, $5, '', NOW(), NOW(), FALSE)
ON CONFLICT(username) DO
UPDATE SET access_token = $3,
refresh_token = $4,
token_expires_at = $5,
is_deleted = false
is_deleted = FALSE
RETURNING id`
return p.conn.QueryRow(
@ -110,7 +110,7 @@ func (p *postgresAccountRepository) Create(ctx context.Context, acc *domain.Acco
INSERT INTO accounts
(username, reddit_account_id, access_token, refresh_token, token_expires_at,
last_message_id, next_notification_check_at, next_stuck_notification_check_at, is_deleted)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, false)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, FALSE)
RETURNING id`
return p.conn.QueryRow(