Class: SidekiqEcsScaler::TaskMetaV4

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq-ecs-scaler/task_meta_v4.rb

Overview

SidekiqEcsScaler::TaskMetaV4

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resp) ⇒ void

Parameters:

  • resp (Hash)


30
31
32
33
# File 'lib/sidekiq-ecs-scaler/task_meta_v4.rb', line 30

def initialize(resp)
  @cluster = resp.fetch("Cluster")
  @task_arn = resp.fetch("TaskARN")
end

Instance Attribute Details

#clusterString (readonly)

Returns:

  • (String)


23
24
25
# File 'lib/sidekiq-ecs-scaler/task_meta_v4.rb', line 23

def cluster
  @cluster
end

#task_arnString (readonly)

Returns:

  • (String)


26
27
28
# File 'lib/sidekiq-ecs-scaler/task_meta_v4.rb', line 26

def task_arn
  @task_arn
end

Class Method Details

.build_or_nullSidekiqEcsScaler::TaskMetaV4?

TODO:

If the metadata acquisition fails, an error will be output to the log.



12
13
14
15
16
17
18
# File 'lib/sidekiq-ecs-scaler/task_meta_v4.rb', line 12

def build_or_null
  ENV.fetch("ECS_CONTAINER_METADATA_URI_V4", nil)&.then do |uri|
    new(JSON.parse(Net::HTTP.get(URI.parse("#{uri}/task"))))
  end
rescue StandardError
  nil
end