class SidekiqEcsScaler::TaskMetaV4

SidekiqEcsScaler::TaskMetaV4

@see docs.aws.amazon.com/AmazonECS/latest/userguide/task-metadata-endpoint-v4-fargate.html

Attributes

cluster[R]

@!attribute [r] cluster @return [String]

task_arn[R]

@!attribute [r] task_arn @return [String]

Public Class Methods

build_or_null() click to toggle source

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

@return [SidekiqEcsScaler::TaskMetaV4, nil]

# 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
new(resp) click to toggle source

@param resp [Hash] @return [void]

# File lib/sidekiq-ecs-scaler/task_meta_v4.rb, line 30
def initialize(resp)
  @cluster = resp.fetch("Cluster")
  @task_arn = resp.fetch("TaskARN")
end