Class: Autoscaler::BinaryScalingStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/autoscaler/binary_scaling_strategy.rb

Overview

Strategies determine the target number of workers The default strategy has a single worker when there is anything, or shuts it down.

Instance Method Summary collapse

Constructor Details

#initialize(active_workers = 1) ⇒ BinaryScalingStrategy

Returns a new instance of BinaryScalingStrategy.

Parameters:

  • active_workers (integer) (defaults to: 1)

    number of workers when in the active state.



6
7
8
# File 'lib/autoscaler/binary_scaling_strategy.rb', line 6

def initialize(active_workers = 1)
  @active_workers = active_workers
end

Instance Method Details

#call(system, event_idle_time) ⇒ Integer

Returns target number of workers.

Parameters:

  • system (QueueSystem)

    interface to the queuing system

  • event_idle_time (Numeric)

    number of seconds since a job related event

Returns:

  • (Integer)

    target number of workers



13
14
15
16
17
18
19
# File 'lib/autoscaler/binary_scaling_strategy.rb', line 13

def call(system, event_idle_time)
  if active?(system)
    @active_workers
  else
    0
  end
end