Sha256: 253eabf1d6f1fc146403e8b14535b867ca1c6e95581526e72c5b097aa7395ddf

Contents?: true

Size: 727 Bytes

Versions: 7

Compression:

Stored size: 727 Bytes

Contents

module Determinator
  module Retrieve
    class RoutemasterFeatureIdCacheWarmer
      def initialize(payload)
        @payload = payload
      end

      def call
        response = client.get(@payload['url']).body
        if valid_feature_response?(response)
          key = Routemaster.index_cache_key(response['name'])
          ::Routemaster::Config.cache_redis.set(key, response['id'])
        end
      end

      private

      def client
        @client ||= ::Routemaster::APIClient.new(
          response_class: ::Routemaster::Responses::HateoasResponse
        )
      end

      def valid_feature_response?(response)
        response['id'] && response['name'] && response['bucket_type']
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
determinator-0.8.0 lib/determinator/retrieve/routemaster_feature_id_cache_warmer.rb
determinator-0.7.0 lib/determinator/retrieve/routemaster_feature_id_cache_warmer.rb
determinator-0.6.2 lib/determinator/retrieve/routemaster_feature_id_cache_warmer.rb
determinator-0.5.0 lib/determinator/retrieve/routemaster_feature_id_cache_warmer.rb
determinator-0.4.0 lib/determinator/retrieve/routemaster_feature_id_cache_warmer.rb
determinator-0.3.0 lib/determinator/retrieve/routemaster_feature_id_cache_warmer.rb
determinator-0.2.0 lib/determinator/retrieve/routemaster_feature_id_cache_warmer.rb