Class: AsyncExperiments::ExperimentResultControlWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
lib/async_experiments/experiment_result_control_worker.rb

Constant Summary collapse

LOCK_TIMEOUT =
60

Instance Method Summary collapse

Instance Method Details

#perform(name, id, run_output, duration, expiry, allowed_attempts = 5, attempt = 1) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/async_experiments/experiment_result_control_worker.rb', line 11

def perform(name, id, run_output, duration, expiry, allowed_attempts = 5, attempt = 1)
  Sidekiq.redis do |redis|
    result = ExperimentResult.new(name, id, :control, redis, statsd, run_output, duration)
    candidate = ExperimentResult.new(name, id, :candidate, redis, statsd)
    if candidate.available?
      result.process_run_output(candidate, expiry)
    elsif allowed_attempts > attempt
      self.class.perform_in(5, name, id, run_output, duration, expiry, allowed_attempts, attempt + 1)
    end
  end
end