Sha256: fc6643fe658ab81ae6d82319dea6dc7650fc091579ec36913343bef808ab06ff
Contents?: true
Size: 1.82 KB
Versions: 3
Compression:
Stored size: 1.82 KB
Contents
require "flipper/adapters/http" require "flipper/instrumenters/noop" module Flipper module Cloud # The default adapter wrapper which doesn't wrap at all. DEFAULT_ADAPTER_WRAPPER_BLOCK = ->(adapter) { adapter } # The default url should be the one, the only, the website. DEFAULT_URL = "https://www.featureflipper.com/adapter".freeze # Public: Returns a new Flipper instance with an http adapter correctly # configured for flipper cloud. # # token - The String token for the environment from the website. # options - The Hash of options. # # :url - The url to point at (defaults to DEFAULT_URL). # # :adapter_wrapper - The adapter wrapper block. Block should # receive an adapter and return an adapter. # Allows you to wrap the http adapter with # other adapters to make instrumentation and # caching easy. # # :instrumenter - The optional instrumenter to use for the # Flipper::DSL instance (defaults to Noop). def self.new(token, options = {}) url = options.fetch(:url, DEFAULT_URL) http_options = { uri: URI(url), headers: { "Feature-Flipper-Token" => token, }, read_timeout: options[:read_timeout], open_timeout: options[:open_timeout], debug_output: options[:debug_output], } adapter = Flipper::Adapters::Http.new(http_options) adapter_wrapper = options.fetch(:adapter_wrapper, DEFAULT_ADAPTER_WRAPPER_BLOCK) adapter = adapter_wrapper.call(adapter) instrumenter = options.fetch(:instrumenter, Flipper::Instrumenters::Noop) Flipper.new(adapter, instrumenter: instrumenter) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
flipper-cloud-0.11.0.beta7 | lib/flipper/cloud.rb |
flipper-cloud-0.11.0.beta6 | lib/flipper/cloud.rb |
flipper-cloud-0.11.0.beta5 | lib/flipper/cloud.rb |