Sha256: 34d8521613691bf741c6612a0e37894722424f582b3c678c58964a043246d029

Contents?: true

Size: 583 Bytes

Versions: 2

Compression:

Stored size: 583 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}"

        @items_cache.fetch(diplomat_key, Diplomat::Kv.get(diplomat_key))
      rescue Diplomat::KeyNotFound
        default
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
blinkist-config-1.0.1 lib/blinkist/config/adapters/diplomat_adapter.rb
blinkist-config-1.0.0 lib/blinkist/config/adapters/diplomat_adapter.rb