Skip to content

Commit 868a502

Browse files
authored
worker/jobs: Use DEDUPLICATED for jobs where it makes sense (#9628)
Most of our background jobs don't need to be enqueued multiple times if there is already a similar one in the queue. This commit changes most of the jobs to use the new `DEDUPLICATED` flag on the `BackgroundJob` impl.
1 parent 6066d18 commit 868a502

18 files changed

+19
-0
lines changed

src/worker/jobs/archive_version_downloads.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ impl Default for ArchiveVersionDownloads {
4848

4949
impl BackgroundJob for ArchiveVersionDownloads {
5050
const JOB_NAME: &'static str = "archive_version_downloads";
51+
const DEDUPLICATED: bool = true;
5152

5253
type Context = Arc<Environment>;
5354

src/worker/jobs/daily_db_maintenance.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub struct DailyDbMaintenance;
1010

1111
impl BackgroundJob for DailyDbMaintenance {
1212
const JOB_NAME: &'static str = "daily_db_maintenance";
13+
const DEDUPLICATED: bool = true;
1314

1415
type Context = Arc<Environment>;
1516

src/worker/jobs/delete_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ impl DeleteCrateFromStorage {
1919

2020
impl BackgroundJob for DeleteCrateFromStorage {
2121
const JOB_NAME: &'static str = "delete_crate_from_storage";
22+
const DEDUPLICATED: bool = true;
2223

2324
type Context = Arc<Environment>;
2425

src/worker/jobs/downloads/clean_processed_log_files.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub struct CleanProcessedLogFiles;
1616

1717
impl BackgroundJob for CleanProcessedLogFiles {
1818
const JOB_NAME: &'static str = "clean_processed_log_files";
19+
const DEDUPLICATED: bool = true;
1920
const QUEUE: &'static str = "downloads";
2021

2122
type Context = Arc<Environment>;

src/worker/jobs/downloads/process_log.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ impl ProcessCdnLog {
4444

4545
impl BackgroundJob for ProcessCdnLog {
4646
const JOB_NAME: &'static str = "process_cdn_log";
47+
const DEDUPLICATED: bool = true;
4748
const QUEUE: &'static str = "downloads";
4849

4950
type Context = Arc<Environment>;

src/worker/jobs/downloads/update_metadata.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct UpdateDownloads;
1414

1515
impl BackgroundJob for UpdateDownloads {
1616
const JOB_NAME: &'static str = "update_downloads";
17+
const DEDUPLICATED: bool = true;
1718

1819
type Context = Arc<Environment>;
1920

src/worker/jobs/dump_db.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct DumpDb;
1414

1515
impl BackgroundJob for DumpDb {
1616
const JOB_NAME: &'static str = "dump_db";
17+
const DEDUPLICATED: bool = true;
1718

1819
type Context = Arc<Environment>;
1920

src/worker/jobs/expiry_notification.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub struct SendTokenExpiryNotifications;
2121

2222
impl BackgroundJob for SendTokenExpiryNotifications {
2323
const JOB_NAME: &'static str = "send_token_expiry_notifications";
24+
const DEDUPLICATED: bool = true;
2425

2526
type Context = Arc<Environment>;
2627

src/worker/jobs/index/squash.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub struct SquashIndex;
1212

1313
impl BackgroundJob for SquashIndex {
1414
const JOB_NAME: &'static str = "squash_index";
15+
const DEDUPLICATED: bool = true;
1516
const QUEUE: &'static str = "repository";
1617

1718
type Context = Arc<Environment>;

src/worker/jobs/index/sync.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ impl SyncToGitIndex {
2828
impl BackgroundJob for SyncToGitIndex {
2929
const JOB_NAME: &'static str = "sync_to_git_index";
3030
const PRIORITY: i16 = 100;
31+
const DEDUPLICATED: bool = true;
3132
const QUEUE: &'static str = "repository";
3233

3334
type Context = Arc<Environment>;
@@ -94,6 +95,7 @@ impl SyncToSparseIndex {
9495
impl BackgroundJob for SyncToSparseIndex {
9596
const JOB_NAME: &'static str = "sync_to_sparse_index";
9697
const PRIORITY: i16 = 100;
98+
const DEDUPLICATED: bool = true;
9799

98100
type Context = Arc<Environment>;
99101

0 commit comments

Comments
 (0)