Class: DynoScaler::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/dyno_scaler/manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/dyno_scaler/manager.rb', line 5

def options
  @options
end

Instance Method Details

#scale_down(options) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/dyno_scaler/manager.rb', line 21

def scale_down(options)
  return unless config.enabled?

  self.options = options

  scale_to(config.min_workers) if scale_down?
end

#scale_down?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/dyno_scaler/manager.rb', line 29

def scale_down?
  options[:workers] > config.min_workers && !pending_jobs? && !working_jobs?
end

#scale_up(options) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/dyno_scaler/manager.rb', line 7

def scale_up(options)
  return unless config.enabled?

  self.options = options

  scale_to(number_of_workers_needed) if scale_up?
end

#scale_up?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
# File 'lib/dyno_scaler/manager.rb', line 15

def scale_up?
  workers_needed = number_of_workers_needed

  pending_jobs? && workers_needed > options[:workers] && workers_needed <= config.max_workers
end

#scale_with(options) ⇒ Object



33
34
35
36
37
38
# File 'lib/dyno_scaler/manager.rb', line 33

def scale_with(options)
  return unless config.enabled?

  action = options[:action] || action_for(options)
  send(action, options) if action
end