Skip to content

Commit

Permalink
fix: Log warning if provided high client init timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
keelerm84 committed May 8, 2024
1 parent 629ecb5 commit e202138
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions lib/ldclient-rb/ldclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,20 @@ def initialize(sdk_key, config = Config.default, wait_for_sec = 5)
end

ready = @data_source.start
if wait_for_sec > 0
ok = ready.wait(wait_for_sec)
if !ok
@config.logger.error { "[LDClient] Timeout encountered waiting for LaunchDarkly client initialization" }
elsif !@data_source.initialized?
@config.logger.error { "[LDClient] LaunchDarkly client initialization failed" }
end

if wait_for_sec < 0
@config.logger.warn { "[LDClient] Instantiated with negative timeout parameter #{wait_for_sec}. Returning immediately." }
elsif wait_for_sec > 60
@config.logger.warn { "[LDClient] Instantiated with high timeout parameter #{wait_for_sec}." }
end

return unless wait_for_sec > 0

ok = ready.wait(wait_for_sec)
if !ok
@config.logger.error { "[LDClient] Timeout encountered waiting for LaunchDarkly client initialization" }
elsif !@data_source.initialized?
@config.logger.error { "[LDClient] LaunchDarkly client initialization failed" }
end
end

Expand Down

0 comments on commit e202138

Please sign in to comment.