class SidekiqBulkJob::JobRetry
Public Class Methods
new(klass, error_handle, options={})
click to toggle source
# File lib/sidekiq_bulk_job/job_retry.rb, line 10 def initialize(klass, error_handle, options={}) @handler = Sidekiq::JobRetry.new(options) @klass = klass @error_handle = error_handle @retry_count = 0 end
Public Instance Methods
push(options={})
click to toggle source
# File lib/sidekiq_bulk_job/job_retry.rb, line 17 def push(options={}) @retry_count = SidekiqBulkJob.redis.incr @error_handle.jid opts = job_options(options) queue_as = queue(@klass) || :default begin @handler.local(SidekiqBulkJob::BulkJob, opts, queue_as) do raise @error_handle.raise_error end rescue Exception => e end end
Protected Instance Methods
job_options(options={})
click to toggle source
# File lib/sidekiq_bulk_job/job_retry.rb, line 31 def job_options(options={}) # 0 retry: no retry and dead queue opts = { 'class' => SidekiqBulkJob::BulkJob.to_s, 'args' => @error_handle.args, 'retry' => true, 'jid' => @error_handle.jid, 'retry_count' => @retry_count.to_i }.merge(options) if Sidekiq::VERSION >= "6.0.2" Sidekiq.dump_json(opts) else opts end end
queue(woker)
click to toggle source
# File lib/sidekiq_bulk_job/job_retry.rb, line 47 def queue(woker) if woker.included_modules.include?(Sidekiq::Worker) && !woker.sidekiq_options.nil? && !woker.sidekiq_options.empty? sidekiq_options = SidekiqBulkJob::Utils.symbolize_keys(woker.sidekiq_options) if !sidekiq_options[:queue].nil? sidekiq_options[:queue] end end end