Class: AsyncExperiments::ExperimentResultWorker

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

Constant Summary collapse

LOCK_TIMEOUT =
60

Instance Method Summary collapse

Instance Method Details

#perform(name, id, run_output, duration, type) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/async_experiments/experiment_result_worker.rb', line 11

def perform(name, id, run_output, duration, type)
  type = type.to_sym

  Sidekiq.redis do |redis|
    this_branch = ExperimentResult.new(name, id, type, redis, statsd, run_output, duration)

    if this_branch.control?
      candidate = ExperimentResult.new(name, id, :candidate, redis, statsd)
      if candidate.available?
        this_branch.process_run_output(candidate)
      else
        self.class.perform_in(5, name, id, run_output, duration, type)
      end
    elsif this_branch.candidate?
      this_branch.store_run_output
    end
  end
end