open-feature/rust-sdk

[SDK] Implement API singleton

toddbaert opened this issue · 3 comments

Currently, there's no means of getting a client without specifying a provider, or a means of setting the global provider instance.

See 1.1.1, 1.1.2, and 1.1.3.

This doesn't feel like a very rust idiom though. When would you want a client without a provider?
When would you use multiple clients that need the same provider but shared globally rather than by scope?

This doesn't seem to advance the project, but more of an implementation detail

When would you want a client without a provider?

It's not that you'd want a client without a provider, it's that there may be one globally configured provider that need not be supplied at the creation of every client, including clients in 3rd party libraries. The global singleton is the mechanism by which 3rd party libraries can add OpenFeature flags and application authors can supply the provider for those flags. Vendor agnostic flags embedded in 3rd party libraries has been a goal since inception (OTel has similar goals).

This doesn't seem to advance the project, but more of an implementation detail

I hope my reasoning above explains why this is in the spec, and why it's not an implementation detail.

I recently proposed the addition of an API like the one you describe, coincidentally. I think it could be helpful (we'd still need the singleton though). See here (I'd love to get more feedback on this).