Skip to content

Commit

Permalink
tweak scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
andremedeiros committed May 22, 2022
1 parent 175bf77 commit b92e3fc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/cmd/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ func SchedulerCmd(ctx context.Context) *cobra.Command {
}

s := gocron.NewScheduler(time.UTC)
_, _ = s.Every(200).Milliseconds().SingletonMode().Do(func() { enqueueAccounts(ctx, logger, statsd, db, redis, luaSha, notifQueue) })
_, _ = s.Every(200).Milliseconds().SingletonMode().Do(func() { enqueueSubreddits(ctx, logger, statsd, db, []rmq.Queue{subredditQueue, trendingQueue}) })
_, _ = s.Every(200).Milliseconds().SingletonMode().Do(func() { enqueueUsers(ctx, logger, statsd, db, userQueue) })
_, _ = s.Every(500).Milliseconds().SingletonMode().Do(func() { enqueueAccounts(ctx, logger, statsd, db, redis, luaSha, notifQueue) })
_, _ = s.Every(500).Milliseconds().SingletonMode().Do(func() { enqueueSubreddits(ctx, logger, statsd, db, []rmq.Queue{subredditQueue, trendingQueue}) })
_, _ = s.Every(500).Milliseconds().SingletonMode().Do(func() { enqueueUsers(ctx, logger, statsd, db, userQueue) })
_, _ = s.Every(1).Second().Do(func() { cleanQueues(logger, queue) })
_, _ = s.Every(1).Second().Do(func() { enqueueStuckAccounts(ctx, logger, statsd, db, stuckNotificationsQueue) })
_, _ = s.Every(1).Minute().Do(func() { reportStats(ctx, logger, statsd, db) })
Expand Down Expand Up @@ -444,7 +444,7 @@ func enqueueAccounts(ctx context.Context, logger *logrus.Logger, statsd *statsd.
WHERE next_notification_check_at < $1
ORDER BY next_notification_check_at
FOR UPDATE SKIP LOCKED
LIMIT 2500
LIMIT 5000
)
RETURNING accounts.id`
rows, err := tx.Query(ctx, stmt, now, next)
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE INDEX watchers_type_watchee_id_idx ON watchers(type int4_ops,watchee_id int4_ops);

0 comments on commit b92e3fc

Please sign in to comment.