Class: JobWorkflow::AutoScaling::Executor
- Inherits:
-
Object
- Object
- JobWorkflow::AutoScaling::Executor
- Defined in:
- lib/job_workflow/auto_scaling/executor.rb,
sig/generated/job_workflow/auto_scaling/executor.rbs
Instance Attribute Summary collapse
- #config ⇒ Configuration readonly
Instance Method Summary collapse
-
#adapter ⇒ Adapter::_InstanceMethods
: () -> Adapter::_InstanceMethods.
-
#desired_count_by_latency ⇒ Integer
: () -> Integer.
-
#desired_count_list ⇒ Array[Integer]
: () -> Array.
-
#initialize(config) ⇒ Executor
constructor
: (Configuration) -> void.
-
#queue_latency ⇒ Integer?
: () -> Integer?.
-
#update_desired_count ⇒ Integer?
: () -> Integer?.
Constructor Details
#initialize(config) ⇒ Executor
: (Configuration) -> void
9 10 11 |
# File 'lib/job_workflow/auto_scaling/executor.rb', line 9 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Configuration (readonly)
20 21 22 |
# File 'lib/job_workflow/auto_scaling/executor.rb', line 20 def config @config end |
Instance Method Details
#adapter ⇒ Adapter::_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_latency ⇒ Integer
: () -> 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_list ⇒ Array[Integer]
: () -> Array
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_latency ⇒ Integer?
: () -> Integer?
28 29 30 |
# File 'lib/job_workflow/auto_scaling/executor.rb', line 28 def queue_latency Queue.latency(config.queue_name) end |
#update_desired_count ⇒ Integer?
: () -> Integer?
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 |