-
Notifications
You must be signed in to change notification settings - Fork 123
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
Delete finished jobs by default, when they're executed #44
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3882cdc
Refactor slightly how executions assume attributes from job
rosa 858d3a4
Simplify a bit how global configuration is initialized in the engine
rosa f410cf6
Simplify tests and fixtures
rosa a691314
Delete finished jobs by default, when they're executed
rosa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ def execute | |
|
||
def finished | ||
transaction do | ||
job.finished | ||
job.finished! | ||
destroy! | ||
end | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
class SolidQueue::Execution < SolidQueue::Record | ||
include JobAttributes | ||
|
||
self.abstract_class = true | ||
|
||
belongs_to :job | ||
|
||
alias_method :discard, :destroy | ||
|
||
private | ||
def assume_attributes_from_job | ||
self.queue_name ||= job&.queue_name | ||
self.priority = job&.priority if job&.priority.to_i > priority | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module SolidQueue | ||
class Execution | ||
module JobAttributes | ||
extend ActiveSupport::Concern | ||
|
||
ASSUMIBLE_ATTRIBUTES_FROM_JOB = %i[ queue_name priority ] | ||
|
||
class_methods do | ||
def assume_attributes_from_job(*attributes) | ||
before_create -> { assume_attributes_from_job(ASSUMIBLE_ATTRIBUTES_FROM_JOB | attributes) } | ||
end | ||
end | ||
|
||
private | ||
def assume_attributes_from_job(attributes) | ||
attributes.each do |attribute| | ||
send("#{attribute}=", job.send(attribute)) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +0,0 @@ | ||
add_to_buffer_job: | ||
queue_name: background | ||
active_job_id: b55784ad-ff9c-4c02-8d6c-016089bb3e09 | ||
class_name: AddToBufferJob | ||
arguments: "{\"job_class\":\"AddToBufferJob\", \"job_id\":\"b55784ad-ff9c-4c02-8d6c-016089bb3e09\", \"provider_job_id\":null, \"queue_name\":\"background\", \"priority\":0, \"arguments\":[42], \"executions\":0, \"exception_executions\":{}, \"locale\":\"en\", \"timezone\":\"UTC\", \"enqueued_at\":\"2023-02-23T09:54:28Z\"}" | ||
priority: 0 | ||
|
||
raising_job: | ||
queue_name: background | ||
class_name: RaisingJob | ||
active_job_id: 60c93269-c3d0-44b1-958e-826cd145c456 | ||
arguments: "{\"job_class\":\"RaisingJob\",\"job_id\":\"60c93269-c3d0-44b1-958e-826cd145c456\",\"provider_job_id\":null,\"queue_name\":\"background\",\"priority\":0,\"arguments\":[{\"_aj_serialized\":\"ActiveJob::Serializers::ModuleSerializer\", \"value\":\"RuntimeError\"}, 2],\"executions\":0,\"exception_executions\":{},\"locale\":\"en\",\"timezone\":\"UTC\",\"enqueued_at\":\"2023-02-23T09:36:04Z\"}" | ||
priority: 0 | ||
|
||
<% 5.times do |i| %> | ||
<% active_job_id = SecureRandom.uuid %> | ||
job_<%= i %>: | ||
queue_name: fixtures | ||
active_job_id: <%= active_job_id %> | ||
class_name: AddToBufferJob | ||
arguments: "{\"job_class\":\"AddToBufferJob\",\"job_id\":\"<%= active_job_id %>\",\"queue_name\":\"fixtures\",\"priority\":<%= i %>,\"arguments\":[],\"executions\":0,\"exception_executions\":{},\"locale\":\"en\",\"timezone\":\"UTC\",\"enqueued_at\":\"2023-02-20T10:33:02Z\"}" | ||
priority: <%= i %> | ||
<% end %> | ||
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
Should we set a default here, now it is not done in the initializer?