Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion launchdarkly-openfeature-server-sdk.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_runtime_dependency "launchdarkly-server-sdk", "~> 8.4"
spec.add_runtime_dependency "launchdarkly-server-sdk", "~> 8.15"
spec.add_runtime_dependency "openfeature-sdk", "~> 0.6.1"

# For more information and examples about making a new gem, check out our
Expand Down
5 changes: 4 additions & 1 deletion lib/ldclient-openfeature/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ class Provider
NUMERIC_TYPES = %i[integer float number].freeze
private_constant :NUMERIC_TYPES

WRAPPER_NAME = "open-feature-ruby-server"
private_constant :WRAPPER_NAME

#
# @param sdk_key [String]
# @param config [LaunchDarkly::Config]
# @param wait_for_seconds [Float]
#
def initialize(sdk_key, config = LaunchDarkly::Config.default, wait_for_seconds = 5)
@client = LaunchDarkly::LDClient.new(sdk_key, config, wait_for_seconds)
@client = LaunchDarkly::LDClient.new(sdk_key, config.with_wrapper_information(WRAPPER_NAME, VERSION), wait_for_seconds)

@logger = config.logger
@context_converter = Impl::EvaluationContextConverter.new(config.logger)
Expand Down
18 changes: 18 additions & 0 deletions spec/provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@
expect(provider.client).to have_received(:close)
end

it "reports itself as the wrapper to LaunchDarkly" do
client = instance_double(
LaunchDarkly::LDClient,
data_source_status_provider: double(add_listener: nil),
flag_tracker: double(add_listener: nil)
)
allow(LaunchDarkly::LDClient).to receive(:new).and_return(client)

described_class.new("example-key", config)

expect(LaunchDarkly::LDClient).to have_received(:new).with(
"example-key",
having_attributes(wrapper_name: "open-feature-ruby-server", wrapper_version: LaunchDarkly::OpenFeature::VERSION),
5
)
expect(config.wrapper_name).to be_nil
end
Comment thread
cursor[bot] marked this conversation as resolved.

it "not providing context returns error" do
resolution_details = provider.fetch_boolean_value(flag_key: "flag-key", default_value: true)

Expand Down
Loading