Sha256: 55f44709a87daf9a838b2306d0399ee5656917368cc20c5146473e5f2443f5b5

Contents?: true

Size: 674 Bytes

Versions: 4

Compression:

Stored size: 674 Bytes

Contents

require_relative "adapter"
require "diplomat"

module Blinkist
  class Config
    class DiplomatAdapter < Adapter
      def initialize(env, app_name)
        super env, app_name

        @items_cache = {}

        Diplomat.configure do |config|
          config.url = "http://172.17.0.1:8500"
        end
      end

      def get(key, default=nil, scope: nil)
        scope ||= @app_name

        diplomat_key = "#{scope}/#{key}"

        unless @items_cache.key? diplomat_key
          @items_cache[diplomat_key] = Diplomat::Kv.get(diplomat_key)
        end

        @items_cache[diplomat_key]
      rescue Diplomat::KeyNotFound
        default
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
blinkist-config-1.2.2 lib/blinkist/config/adapters/diplomat_adapter.rb
blinkist-config-1.2.0 lib/blinkist/config/adapters/diplomat_adapter.rb
blinkist-config-1.1.0 lib/blinkist/config/adapters/diplomat_adapter.rb
blinkist-config-1.0.2 lib/blinkist/config/adapters/diplomat_adapter.rb