Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2050,6 +2050,12 @@ Change search queue name
Searchkick.queue_name = :search_reindex
```
Change the parent job (default to `"ActiveJob::Base"`)
```ruby
Searchkick.parent_job = "ApplicationJob"
```
Eager load associations
```ruby
Expand Down
3 changes: 2 additions & 1 deletion lib/searchkick.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class DangerousOperation < Error; end
class ImportError < Error; end

class << self
attr_accessor :search_method_name, :timeout, :models, :client_options, :redis, :index_prefix, :index_suffix, :queue_name, :model_options, :client_type
attr_accessor :search_method_name, :timeout, :models, :client_options, :redis, :index_prefix, :index_suffix, :queue_name, :model_options, :client_type, :parent_job
attr_writer :client, :env, :search_timeout
attr_reader :aws_credentials
end
Expand All @@ -67,6 +67,7 @@ class << self
self.client_options = {}
self.queue_name = :searchkick
self.model_options = {}
self.parent_job = "ActiveJob::Base"

def self.client
@client ||= begin
Expand Down
2 changes: 1 addition & 1 deletion lib/searchkick/bulk_reindex_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Searchkick
class BulkReindexJob < ActiveJob::Base
class BulkReindexJob < Searchkick.parent_job.constantize
queue_as { Searchkick.queue_name }

# TODO remove min_id and max_id in Searchkick 6
Expand Down
2 changes: 1 addition & 1 deletion lib/searchkick/process_batch_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Searchkick
class ProcessBatchJob < ActiveJob::Base
class ProcessBatchJob < Searchkick.parent_job.constantize
queue_as { Searchkick.queue_name }

def perform(class_name:, record_ids:, index_name: nil)
Expand Down
2 changes: 1 addition & 1 deletion lib/searchkick/process_queue_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Searchkick
class ProcessQueueJob < ActiveJob::Base
class ProcessQueueJob < Searchkick.parent_job.constantize
queue_as { Searchkick.queue_name }

def perform(class_name:, index_name: nil, inline: false)
Expand Down
2 changes: 1 addition & 1 deletion lib/searchkick/reindex_v2_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Searchkick
class ReindexV2Job < ActiveJob::Base
class ReindexV2Job < Searchkick.parent_job.constantize
queue_as { Searchkick.queue_name }

def perform(class_name, id, method_name = nil, routing: nil, index_name: nil)
Expand Down