Skip to content

feat: Openfeature Provider Update #280

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

Merged
merged 7 commits into from
Mar 11, 2025
Merged

Conversation

JamieSinn
Copy link
Member

No description provided.

@JamieSinn JamieSinn marked this pull request as ready for review March 10, 2025 15:39
@JamieSinn JamieSinn requested review from a team March 10, 2025 15:39
@JamieSinn JamieSinn enabled auto-merge (squash) March 10, 2025 18:35
for {
time.Sleep(time.Millisecond * 100)
event := <-inithandler
if event.EventType == api.ClientEventType_Initialized {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make more sense to use the initialized method on the provider?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - because we need a guaranteed return status and this event is the guarantee - I was fighting race conditions with the initialized method

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the OF one not guarantee to return?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope - it can return an error

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea so can we catch the error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That won't do what we want here - which is to guarantee the sdk has initialized before doing any openfeature operations.

The provider just returns whether or not there's handling done in specifically the provider for init - so we need to wait for the client to init itself. The status function in the provider has no context to the client to know whether or not it's been initialized - just closed - https://github.com/DevCycleHQ/go-server-sdk/pull/280/files#diff-68983a7a553e04797e31fac83289f03d99f68a233e874a2d0d9ea56efb2f36d7R63-R68
We have this because otherwise the calls will always fail and throw an exception of "provider not initialized" when that's not true and the provider can handle the request.
We specifically do this because the sdk can handle defaults before init is complete.

The SDK is the only true source - hence waiting on the initialization event from the SDK to be emitted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea all I'm getting at here, is that we really should be trying to have these examples use the OpenFeature "native" way as much as possible, as that's what our customers will expect when they come to us for OpenFeature SDKs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep - agreed - though our initialization handling across all our SDKs is tricky and handled differently per language.

@JamieSinn JamieSinn merged commit af912af into main Mar 11, 2025
8 checks passed
@JamieSinn JamieSinn deleted the jamie/of-provider-updates branch March 11, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants