Class: JobWorkflow::AutoScaling::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/job_workflow/auto_scaling/executor.rb,
sig/generated/job_workflow/auto_scaling/executor.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Executor

: (Configuration) -> void

Parameters:



9
10
11
# File 'lib/job_workflow/auto_scaling/executor.rb', line 9

def initialize(config)
  @config = config
end

Instance Attribute Details

#configConfiguration (readonly)

Signature:

  • Configuration

Returns:



20
21
22
# File 'lib/job_workflow/auto_scaling/executor.rb', line 20

def config
  @config
end

Instance Method Details

#adapterAdapter::_InstanceMethods

: () -> Adapter::_InstanceMethods



23
24
25
# File 'lib/job_workflow/auto_scaling/executor.rb', line 23

def adapter
  @adapter ||= Adapter.fetch(:aws).new
end

#desired_count_by_latencyInteger

: () -> Integer

Returns:

  • (Integer)


33
34
35
36
37
# File 'lib/job_workflow/auto_scaling/executor.rb', line 33

def desired_count_by_latency
  latency = queue_latency || 0

  desired_count_list.at((latency.to_f / config.latency_per_step_count).floor.to_i) || config.max_count
end

#desired_count_listArray[Integer]

: () -> Array

Returns:

  • (Array[Integer])


40
41
42
# File 'lib/job_workflow/auto_scaling/executor.rb', line 40

def desired_count_list
  config.min_count.step(config.max_count, config.step_count).to_a #: Array[Integer]
end

#queue_latencyInteger?

: () -> Integer?

Returns:

  • (Integer, nil)


28
29
30
# File 'lib/job_workflow/auto_scaling/executor.rb', line 28

def queue_latency
  Queue.latency(config.queue_name)
end

#update_desired_countInteger?

: () -> Integer?

Returns:

  • (Integer, nil)


14
15
16
# File 'lib/job_workflow/auto_scaling/executor.rb', line 14

def update_desired_count
  adapter.update_desired_count(desired_count_by_latency)
end