Class: Chewy::Strategy::DelayedSidekiq

Inherits:
Sidekiq show all
Defined in:
lib/chewy/strategy/delayed_sidekiq.rb,
lib/chewy/strategy/delayed_sidekiq/worker.rb,
lib/chewy/strategy/delayed_sidekiq/scheduler.rb

Defined Under Namespace

Classes: Scheduler, Worker

Class Method Summary collapse

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

Class Method Details

.clear_timechunks!Object

cleanup the redis sets used internally. Useful mainly in tests to avoid leak and potential flaky tests.



10
11
12
13
14
15
16
17
18
19
# File 'lib/chewy/strategy/delayed_sidekiq.rb', line 10

def self.clear_timechunks!
  ::Sidekiq.redis do |redis|
    timechunk_sets = redis.smembers(Chewy::Strategy::DelayedSidekiq::Scheduler::ALL_SETS_KEY)
    break if timechunk_sets.empty?

    redis.pipelined do |pipeline|
      timechunk_sets.each { |set| pipeline.del(set) }
    end
  end
end

Instance Method Details

#leaveObject



21
22
23
24
25
26
27
# File 'lib/chewy/strategy/delayed_sidekiq.rb', line 21

def leave
  @stash.each do |type, ids|
    next if ids.empty?

    DelayedSidekiq::Scheduler.new(type, ids).postpone
  end
end