Class: LaunchDarkly::OpenFeature::Provider

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclient-openfeature/provider.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sdk_key, config = LaunchDarkly::Config.default, wait_for_seconds = 5) ⇒ Provider

Returns a new instance of Provider.

Parameters:

  • sdk_key (String)
  • config (LaunchDarkly::Config) (defaults to: LaunchDarkly::Config.default)
  • wait_for_seconds (Float) (defaults to: 5)


33
34
35
36
37
38
39
40
# File 'lib/ldclient-openfeature/provider.rb', line 33

def initialize(sdk_key, config = LaunchDarkly::Config.default, wait_for_seconds = 5)
  @client = LaunchDarkly::LDClient.new(sdk_key, config, wait_for_seconds)

  @context_converter = Impl::EvaluationContextConverter.new(config.logger)
  @details_converter = Impl::ResolutionDetailsConverter.new

  @metadata = ::OpenFeature::SDK::Provider::ProviderMetadata.new(name: "launchdarkly-openfeature-server").freeze
end

Instance Attribute Details

#clientLaunchDarkly::LDClient (readonly)

Access the underlying LaunchDarky client instance backing this provider.

This is useful for accessing additional functionality not exposed by the provider.

Returns:

  • (LaunchDarkly::LDClient)


23
24
25
# File 'lib/ldclient-openfeature/provider.rb', line 23

def client
  @client
end

#metadata::OpenFeature::SDK::Provider::ProviderMetadata (readonly)

Retrieve metadata information describing this provider.

Returns:

  • (::OpenFeature::SDK::Provider::ProviderMetadata)


14
15
16
# File 'lib/ldclient-openfeature/provider.rb', line 14

def 
  @metadata
end

Instance Method Details

#fetch_boolean_value(flag_key:, default_value:, evaluation_context: nil) ⇒ Object



42
43
44
# File 'lib/ldclient-openfeature/provider.rb', line 42

def fetch_boolean_value(flag_key:, default_value:, evaluation_context: nil)
  resolve_value(:boolean, flag_key, default_value, evaluation_context)
end

#fetch_float_value(flag_key:, default_value:, evaluation_context: nil) ⇒ Object



58
59
60
# File 'lib/ldclient-openfeature/provider.rb', line 58

def fetch_float_value(flag_key:, default_value:, evaluation_context: nil)
  resolve_value(:float, flag_key, default_value, evaluation_context)
end

#fetch_integer_value(flag_key:, default_value:, evaluation_context: nil) ⇒ Object



54
55
56
# File 'lib/ldclient-openfeature/provider.rb', line 54

def fetch_integer_value(flag_key:, default_value:, evaluation_context: nil)
  resolve_value(:integer, flag_key, default_value, evaluation_context)
end

#fetch_number_value(flag_key:, default_value:, evaluation_context: nil) ⇒ Object



50
51
52
# File 'lib/ldclient-openfeature/provider.rb', line 50

def fetch_number_value(flag_key:, default_value:, evaluation_context: nil)
  resolve_value(:number, flag_key, default_value, evaluation_context)
end

#fetch_object_value(flag_key:, default_value:, evaluation_context: nil) ⇒ Object



62
63
64
# File 'lib/ldclient-openfeature/provider.rb', line 62

def fetch_object_value(flag_key:, default_value:, evaluation_context: nil)
  resolve_value(:object, flag_key, default_value, evaluation_context)
end

#fetch_string_value(flag_key:, default_value:, evaluation_context: nil) ⇒ Object



46
47
48
# File 'lib/ldclient-openfeature/provider.rb', line 46

def fetch_string_value(flag_key:, default_value:, evaluation_context: nil)
  resolve_value(:string, flag_key, default_value, evaluation_context)
end