-
Notifications
You must be signed in to change notification settings - Fork 760
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
Add parent_job attr to change jobs inheritance #1478
base: master
Are you sure you want to change the base?
Conversation
Hey @kevynlebouille, thanks for the PR (and sorry for the long delay)! Can you explain more about the use case? |
Hi @ankane , with a multi-tenant context, I need to set a Current attribute while indexing. Long story short, below my code sample from my initializer: module Searchkick
module TenantJobDecorator
def self.prepended(base)
base.attr_accessor :current_project
base.around_perform do |job, block|
Current.set(project: job.current_project || Current.project, &block)
end
end
def serialize
super.merge('project_id' => Current.project&.id)
end
def deserialize(job_data)
super
self.current_project = Project.find_by(id: job_data['project_id'])
end
end
end
Searchkick::BulkReindexJob.prepend Searchkick::TenantJobDecorator
Searchkick::ProcessBatchJob.prepend Searchkick::TenantJobDecorator
Searchkick::ProcessQueueJob.prepend Searchkick::TenantJobDecorator
Searchkick::ReindexV2Job.prepend Searchkick::TenantJobDecorator Cheers, |
I also find it very useful when using |
This would be very useful for us as well 👍 Our use case is that we have statistics tracking and retry logic defined in our ApplicationJob. Currently we have to open all the job classes and monkey patch them with the same logic (and keep track of changes regarding new jobs in this project) |
3e460c9
to
02cd61b
Compare
Hi @ankane , it's the come back of my PR (freshly rebased). If you don't want to merged that PR, could you explain quickly why ? Thx |
20c1001
to
c5a2525
Compare
c5a2525
to
87c68e5
Compare
Hi @ankane , I just rebased my PR, keep hope! |
Hi,
In order to add some callbacks to Searchkick jobs or use new features from ActiveJob, it could be nice to have a config option to change the default inheritance.
This is also an opportunity to thank you for this awesome gem!
Kevyn