Sha256: f4fd30759e4b8027558822968bf54d1c2de73e14630a7845c2c2a5773087b18e
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
# frozen_string_literal: true require "forwardable" require "singleton" require_relative "configuration" require_relative "client" require_relative "metadata" require_relative "provider/no_op_provider" module OpenFeature module SDK # API Initialization and Configuration # # Represents the entry point to the API, including configuration of <tt>Provider</tt>,<tt>Hook</tt>, # and building the <tt>Client</tt> # # To use the SDK, you can optionally configure a <tt>Provider</tt>, with <tt>Hook</tt> # # OpenFeature::SDK::API.instance.configure do |config| # config.provider = NoOpProvider.new # end # # If no provider is specified, the <tt>NoOpProvider</tt> is set as the default <tt>Provider</tt>. # Once the SDK has been configured, a client can be built # # client = OpenFeature::SDK::API.instance.build_client(name: 'my-open-feature-client') class API include Singleton extend Forwardable def_delegator :@configuration, :provider def_delegator :@configuration, :hooks def_delegator :@configuration, :context def configuration @configuration ||= Configuration.new end def configure(&block) return unless block_given? block.call(configuration) end def build_client(name: nil, version: nil) client_options = Metadata.new(name: name, version: version).freeze provider = Provider::NoOpProvider.new if provider.nil? Client.new(provider: provider, client_options: client_options, context: context) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
openfeature-sdk-0.1.1 | lib/openfeature/sdk/api.rb |
openfeature-sdk-0.1.0 | lib/openfeature/sdk/api.rb |