Module: Scalehero

Defined in:
lib/scalehero.rb,
lib/scalehero/version.rb

Defined Under Namespace

Modules: Scaler

Constant Summary collapse

VERSION =
"0.0.3"

Instance Method Summary collapse

Instance Method Details

#after_enqueue_scale_up(*args) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/scalehero.rb', line 36

def after_enqueue_scale_up(*args)
  [
    {:workers => 1,:job_count => 1},
    {:workers => 2,:job_count => 15},
    {:workers => 3,:job_count => 25},
    {:workers => 4,:job_count => 40},
    {:workers => 5,:job_count => 60}
  ].reverse_each do |scale_info|
    if Scaler.pending_jobs_count >= scale_info[:job_count]
      if Scaler.workers.count <= scale_info[:workers]
        Scaler.workers = scale_info[:workers]
      end
      break
    end
  end
end

#after_perform_scale_down(*args) ⇒ Object



32
33
34
# File 'lib/scalehero.rb', line 32

def after_perform_scale_down(*args)
  Scaler.workers = 0 if Scaler.workers.count.zero? && Scaler.has_one_working_job?
end