diff options
author | 2023-10-20 15:12:02 -0700 | |
---|---|---|
committer | 2023-10-20 16:07:18 -0700 | |
commit | 4cc99881d870495ef35dcbb44d351e4b3c01f401 (patch) | |
tree | 46c1408d9a8eba7fdf7633201902e18c6094e579 /internal/cli/scheduler.go | |
parent | 95ee1c423b1157a967fb2024aa86bd395ead23f8 (diff) | |
download | v2-4cc99881d870495ef35dcbb44d351e4b3c01f401.tar.gz v2-4cc99881d870495ef35dcbb44d351e4b3c01f401.tar.zst v2-4cc99881d870495ef35dcbb44d351e4b3c01f401.zip |
Refactor Batch Builder and prevent accidental and excessive refreshes from the web ui
Diffstat (limited to 'internal/cli/scheduler.go')
-rw-r--r-- | internal/cli/scheduler.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/internal/cli/scheduler.go b/internal/cli/scheduler.go index 6bde37c0..9f69d7ea 100644 --- a/internal/cli/scheduler.go +++ b/internal/cli/scheduler.go @@ -20,6 +20,7 @@ func runScheduler(store *storage.Storage, pool *worker.Pool) { pool, config.Opts.PollingFrequency(), config.Opts.BatchSize(), + config.Opts.PollingParsingErrorLimit(), ) go cleanupScheduler( @@ -28,10 +29,16 @@ func runScheduler(store *storage.Storage, pool *worker.Pool) { ) } -func feedScheduler(store *storage.Storage, pool *worker.Pool, frequency, batchSize int) { +func feedScheduler(store *storage.Storage, pool *worker.Pool, frequency, batchSize, errorLimit int) { for range time.Tick(time.Duration(frequency) * time.Minute) { - jobs, err := store.NewBatch(batchSize) - if err != nil { + // Generate a batch of feeds for any user that has feeds to refresh. + batchBuilder := store.NewBatchBuilder() + batchBuilder.WithBatchSize(batchSize) + batchBuilder.WithErrorLimit(errorLimit) + batchBuilder.WithoutDisabledFeeds() + batchBuilder.WithNextCheckExpired() + + if jobs, err := batchBuilder.FetchJobs(); err != nil { slog.Error("Unable to fetch jobs from database", slog.Any("error", err)) } else { slog.Info("Created a batch of feeds", |