Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds first-class unique job support to
laravel::queueand queued event listeners with zero new dependencies and zero breaking changes.Summary of Changes
#[job]/#[listener(queued)]&JobOptions(macros/queue/src/{job,listener,slack}.rs,crates/queue/src/queue/job.rs,crates/events/src/event/queued.rs):unique,unique_until_processing,unique_for = <duration>(24h default; enablesuniquewhen used alone), andunique_via = "<store>"options, plus per-instanceunique_id(&self) -> impl Displayand optional dynamicunique_for(&self)/unique_via(&self)methods.unique+unique_until_processing,debounce_for+unique*, Slack actions with unique options).crates/queue/src/queue/{unique,dispatch,payload,attempt,chain,worker}.rs,commands/failed.rs,src/testing/queue.rs):laravel:unique:{job}:{id}) insideafter_commit(so rolled-back DB transactions never acquire locks) and attaches compactOption<Box<UniqueLock>>metadata only when needed (zero payload JSON change for non-unique jobs).Ended::Skipped; pushing unique jobs individually inqueue::bulk).uniquemode holds the lock across retries/releases and releases owner-safely (restore_lock(&key, &owner).release()) on completion, deletion, missing models, or permanent failure (beforefailed()hooks);unique_until_processingreleases right beforehandle()starts (still cleaning up if middleware deletes/fails beforehandle()).syncdriver, push failures,discardconnections,queue::fake()(includingapp.travel(...)expiry), chains, batches, and queued listeners cleanly whiledispatch_sync,queue:retry, andapp.job(...)bypass unique locks.### Unique jobsindocs/queues.mdand adds unit, macro-error, and 15 end-to-end integration tests intests/queue_unique.rs.Verification
cargo fmt --check: passcargo clippy -p laravel-rust-queue -p laravel-rust-queue-macros -p laravel-rust-events --all-targets -- -D warnings: pass (0 warnings)cargo clippy --features s3,database-sqlite,database-postgres,database-mysql --test queue -- -D warnings: pass (0 warnings)cargo test -p laravel-rust-queue -p laravel-rust-queue-macros --lib: 33 passed, 0 failedcargo test --no-default-features --test queue queue_unique: 7 passed, 0 failedcargo test --features database-sqlite --test queue: 355 passed, 0 failed (2 ignored)