class ChewyResque::Worker

Public Class Methods

index(index_name, ids) click to toggle source
# File lib/chewy_resque/worker.rb, line 22
def self.index(index_name, ids)
  ActiveSupport::Notifications.instrument('index.chewy_resque', index_name: index_name, ids: ids) do
    with_strategy do
      Chewy.derive_type(index_name).update_index(ids)
    end
  end
end
perform(index_name, ids) click to toggle source
# File lib/chewy_resque/worker.rb, line 11
def self.perform(index_name, ids)
  ActiveSupport::Notifications.instrument('perform.chewy_resque', index_name: index_name, ids: ids) do
    with_lock(index_name, ids)
  end
end
queue() click to toggle source
# File lib/chewy_resque/worker.rb, line 7
def self.queue
  ChewyResque::locking_scope
end
with_lock(index_name, ids) click to toggle source
# File lib/chewy_resque/worker.rb, line 17
def self.with_lock(index_name, ids)
  lock_name = "chewy-resque:#{ChewyResque.locking_scope}:#{index_name}-#{ids.join('-')}"
  Resque.redis.lock(lock_name, life: 60, acquire: 5) { index(index_name, ids) }
end
with_strategy() { || ... } click to toggle source
# File lib/chewy_resque/worker.rb, line 30
def self.with_strategy
  if Chewy.respond_to?(:strategy) && Chewy.strategy.current.name == :base
    # production
    begin
      Chewy.strategy(:atomic)
      yield
    ensure
      Chewy.strategy.pop
    end
  else
    # 0.6.2 or test
    yield
  end
end