class Chewy::Strategy::Sidekiq

The strategy works the same way as atomic, but performs async index update driven by sidekiq

Chewy.strategy(:sidekiq) do
  User.all.map(&:save) # Does nothing here
  Post.all.map(&:save) # And here
  # It imports all the changed users and posts right here
end

Public Instance Methods

leave() click to toggle source
# File lib/chewy/strategy/sidekiq.rb, line 22
def leave
  @stash.each do |type, ids|
    next if ids.empty?

    ::Sidekiq::Client.push(
      'queue' => sidekiq_queue,
      'class' => Chewy::Strategy::Sidekiq::Worker,
      'args'  => [type.name, ids]
    )
  end
end

Private Instance Methods

sidekiq_queue() click to toggle source
# File lib/chewy/strategy/sidekiq.rb, line 36
def sidekiq_queue
  Chewy.settings.dig(:sidekiq, :queue) || 'chewy'
end