Skip to content

feat: Support provider initialization and shutdown - #28

Open
kinyoklion wants to merge 1 commit into
mainfrom
devin/ruby-lifecycle
Open

feat: Support provider initialization and shutdown#28
kinyoklion wants to merge 1 commit into
mainfrom
devin/ruby-lifecycle

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Aug 19, 2026

Copy link
Copy Markdown
Member

Implements the OpenFeature provider lifecycle hooks so the OpenFeature SDK can reflect LaunchDarkly initialization failures and release resources.

  • Adds Provider#init, which raises when the LaunchDarkly client did not initialize, so the OpenFeature SDK moves the provider to ERROR instead of reporting READY.
  • Adds Provider#shutdown, which closes the LaunchDarkly client when the provider is replaced or OpenFeature::SDK.shutdown is called.
  • The LaunchDarkly client is still created in the constructor, matching the Java provider; a client cannot be restarted, so a new provider instance is required after shutdown.
Implementation details

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Part of an audit of the LaunchDarkly OpenFeature providers against the current OpenFeature specification. Provider lifecycle (spec sections 2.4 / 1.7) was unimplemented here: initialization failures were invisible to the OpenFeature SDK, and shutting down the OpenFeature SDK leaked the LaunchDarkly client's connections and event processor.

Describe the solution you've provided

OpenFeature::SDK::Configuration calls init on providers that respond to it and dispatches PROVIDER_READY on success, or PROVIDER_ERROR when init raises; it calls shutdown on providers that respond to it. init uses LDClient#initialized? and includes the data source state from data_source_status_provider in the raised error message for diagnosability.

Describe alternatives you've considered

Deferring LaunchDarkly client construction to init — rejected because it would change the meaning of the existing public client accessor and the constructor's wait_for_seconds argument. Blocking inside init on a data source status listener — rejected as redundant, since the constructor already waits, and later state changes are better delivered as provider events.

Testing

bundle exec rake (RSpec + RuboCop) on Ruby 3.4: 57 examples, 0 failures; 12 files inspected, no offenses. Ruby 3.4 was used because the gemspec requires >= 3.4.

@cursor review

Link to Devin session: https://app.devin.ai/sessions/0c452d209ec54b068ba120b4c92b8f6c
Requested by: @kinyoklion


Note

Overview
Implements OpenFeature provider lifecycle hooks so the SDK can surface LaunchDarkly init failures and release resources on teardown.

init runs after the constructor has already waited on the LD client; if initialized? is false, it raises with the data source state so OpenFeature reports PROVIDER_ERROR instead of READY. shutdown calls @client.close when the provider is replaced or the SDK shuts down (a new provider instance is required afterward, matching the Java provider).

Specs cover successful init, failed init, and shutdown closing the client.

Reviewed by Cursor Bugbot for commit f45d6c6. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
@kinyoklion kinyoklion self-assigned this Aug 19, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot added the devin-pr PRs created by Devin label Aug 19, 2026
@kinyoklion
kinyoklion marked this pull request as ready for review August 19, 2026 16:55
@kinyoklion
kinyoklion requested a review from a team as a code owner August 19, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devin-pr PRs created by Devin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant