Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Calling stop in ldd mode no longer raises an exception #235

Merged
merged 2 commits into from
Dec 26, 2023
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 lib/ldclient-rb/impl/integrations/redis_impl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def initialize(opts)
@pool = create_redis_pool(opts)

# shutdown pool on close unless the client passed a custom pool and specified not to shutdown
@pool_shutdown_on_close = (!opts[:pool] || opts.fetch(:pool_shutdown_on_close, true))
@pool_shutdown_on_close = !opts[:pool] || opts.fetch(:pool_shutdown_on_close, true)

@prefix = opts[:prefix] || LaunchDarkly::Integrations::Redis::default_prefix
@logger = opts[:logger] || Config.default_logger
Expand Down
1 change: 1 addition & 0 deletions lib/ldclient-rb/ldclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def initialize(sdk_key, config = Config.default, wait_for_sec = 5)

if @config.use_ldd?
@config.logger.info { "[LDClient] Started LaunchDarkly Client in LDD mode" }
@data_source = NullUpdateProcessor.new
return # requestor and update processor are not used in this mode
end

Expand Down
17 changes: 17 additions & 0 deletions spec/ldclient_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ module LaunchDarkly
end
end

context "client can be stopped" do
it "when in online mode" do
client = subject.new("sdk-key", Config.new)
client.close()
end

it "when in offline mode" do
client = subject.new("sdk-key", Config.new(offline: true))
client.close()
end

it "when in ldd mode" do
client = subject.new("sdk-key", Config.new(use_ldd: true))
client.close()
end
end

context "secure_mode_hash" do
it "will return the expected value for a known message and secret" do
ensure_close(subject.new("secret", test_config)) do |client|
Expand Down