run scheduler 5 times per second

This commit is contained in:
Andre Medeiros 2021-07-22 21:35:11 -04:00
parent cbcab2a992
commit 424e27b068

View file

@ -67,7 +67,7 @@ func SchedulerCmd(ctx context.Context) *cobra.Command {
} }
s := gocron.NewScheduler(time.UTC) s := gocron.NewScheduler(time.UTC)
s.Every(1).Second().SingletonMode().Do(func() { enqueueAccounts(ctx, logger, statsd, db, redis, luaSha, notifQueue) }) s.Every(200).Milliseconds().SingletonMode().Do(func() { enqueueAccounts(ctx, logger, statsd, db, redis, luaSha, notifQueue) })
s.Every(1).Second().Do(func() { cleanQueues(ctx, logger, queue) }) s.Every(1).Second().Do(func() { cleanQueues(ctx, logger, queue) })
s.Every(1).Minute().Do(func() { reportStats(ctx, logger, statsd, db, redis) }) s.Every(1).Minute().Do(func() { reportStats(ctx, logger, statsd, db, redis) })
s.Every(1).Minute().Do(func() { cleanAccounts(ctx, logger, db) }) s.Every(1).Minute().Do(func() { cleanAccounts(ctx, logger, db) })
@ -210,7 +210,7 @@ func enqueueAccounts(ctx context.Context, logger *logrus.Logger, statsd *statsd.
last_enqueued_at < $1 last_enqueued_at < $1
OR last_checked_at < $2 OR last_checked_at < $2
ORDER BY last_checked_at ORDER BY last_checked_at
LIMIT 2000 LIMIT 1000
FOR UPDATE SKIP LOCKED FOR UPDATE SKIP LOCKED
) )
UPDATE accounts UPDATE accounts