-
-
Notifications
You must be signed in to change notification settings - Fork 5
Fix scheduled job handling in adapter #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,15 +76,15 @@ | |
| end | ||
|
|
||
| it "can enqueue a job at specific time" do | ||
| adapter.enqueue_at(job, timestamp) | ||
| adapter.enqueue_at(job, timestamp.to_f) | ||
|
|
||
| Sync do | ||
| serialized_job = buffer.pop | ||
| expect(serialized_job).to have_keys( | ||
| "job_class" => be == "TestJob", | ||
| "queue_name" => be == "default", | ||
| "arguments" => be == [], | ||
| "scheduled_at" => be == timestamp.iso8601(9), | ||
| "scheduled_at" => be == job.scheduled_at.iso8601(9), | ||
| ) | ||
| end | ||
| end | ||
|
|
@@ -93,7 +93,39 @@ | |
| # This test verifies that the job gets dispatched successfully at a specific time | ||
| # The Sync wrapper is tested implicitly by the successful enqueueing | ||
| expect(dispatcher.queues["default"]).to be_a(Object) | ||
| adapter.enqueue_at(job, timestamp) | ||
| adapter.enqueue_at(job, timestamp.to_f) | ||
| end | ||
| end | ||
|
|
||
| with "job with :wait option" do | ||
| let(:adapter) {subject.new(dispatcher)} | ||
| let(:job) {TestJob.new} | ||
| let(:wait) {0.second} | ||
|
|
||
| before do | ||
| dispatcher.queues["default"] = queue | ||
| job.set(wait:) | ||
| end | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other spec tests that calling This new spec tests that setting it on the job as you're supposed to (via We might not want to support the former test, but again, leaving it just in case we want to guarantee that. |
||
|
|
||
| it "can enqueue a job with :wait option" do | ||
| adapter.enqueue_at(job, job.scheduled_at.to_f) | ||
|
|
||
| Sync do | ||
| serialized_job = buffer.pop | ||
| expect(serialized_job).to have_keys( | ||
| "job_class" => be == "TestJob", | ||
| "queue_name" => be == "default", | ||
| "arguments" => be == [], | ||
| "scheduled_at" => be == job.scheduled_at.utc.iso8601(9), | ||
| ) | ||
| end | ||
| end | ||
|
|
||
| it "successfully dispatches job through Sync wrapper" do | ||
| # This test verifies that the job gets dispatched successfully at a specific time | ||
| # The Sync wrapper is tested implicitly by the successful enqueueing | ||
| expect(dispatcher.queues["default"]).to be_a(Object) | ||
| adapter.enqueue_at(job, job.scheduled_at.to_f) | ||
| end | ||
| end | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, since this is an Active Job adapter, I'd suggest just removing it since we know jobs will already come with
scheduled_atset, but I'm leaving it there just in case we want to guarantee that#enqueue_atsets it on the job when passing a timestamp.I understand that commit 3b4fd0b -
Fix handling of scheduled jobs.added this so there might be a more nuanced reason why we make sure its set here, so that's yet another reason why I'm not blindly removing it.