Class: Chewy::Strategy::Sidekiq

Inherits:
Atomic show all
Defined in:
lib/chewy/strategy/sidekiq.rb

Overview

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

Direct Known Subclasses

LazySidekiq

Defined Under Namespace

Classes: Worker

Instance Method Summary collapse

Methods inherited from Atomic

#initialize, #update

Methods inherited from Base

#name, #update, #update_chewy_indices

Constructor Details

This class inherits a constructor from Chewy::Strategy::Atomic

Instance Method Details

#leaveObject



22
23
24
25
26
27
28
29
30
31
32
# 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