Class: Blinkist::Config::AwsSsmAdapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/blinkist/config/adapters/aws_ssm_adapter.rb

Constant Summary collapse

DEFAULT_PREFIX =
"/application/".freeze

Instance Method Summary collapse

Methods inherited from Adapter

instance_for

Constructor Details

#initialize(env, app_name) ⇒ AwsSsmAdapter

Returns a new instance of AwsSsmAdapter.



9
10
11
12
13
14
# File 'lib/blinkist/config/adapters/aws_ssm_adapter.rb', line 9

def initialize(env, app_name)
  super

  @items_cache = {}
  @client = Aws::SSM::Client.new
end

Instance Method Details

#get(key, default = nil, scope: nil, refetch: false) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/blinkist/config/adapters/aws_ssm_adapter.rb', line 16

def get(key, default = nil, scope: nil, refetch: false)
  prefix = prefix_for(scope)

  query_ssm_parameter(prefix + key, refetch)
rescue Aws::SSM::Errors::ParameterNotFound
  default
end

#preload(scope: nil) ⇒ Object



24
25
26
# File 'lib/blinkist/config/adapters/aws_ssm_adapter.rb', line 24

def preload(scope: nil)
  query_all_ssm_parameters prefix_for(scope)
end