Skip to content

Commit

Permalink
Add parent_job attr to change inheritance af jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
kevynlebouille committed Jan 13, 2025
1 parent dc05b1d commit 20c1001
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
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

0 comments on commit 20c1001

Please sign in to comment.