-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: buildAndInit for isolated client instances #166
base: main
Are you sure you want to change the base?
Conversation
5c466e9
to
a73bf0c
Compare
Several false starts and iterations later, we're ready for another review. Note: this PR is now stacked on #170 where changes are made just to how the singleton is referenced, leaving the focus of this PR on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Main feedback is around documentation and providing alternative APIs for what's been deprecated. I'm ready to approve after that, great work!
Thank you, @rasendubi @felipecsl @aarsilv for you reviews and patience as we explore this change. I have made a key change - the singleton PTAL |
labels: mergeable
Eppo Internal
ποΈ Fixes: FF-3888
π Multiple Eppo Clients
Configuration Side-loading
Motivation and Context
The
init
andgetInstance()
methods work on a singleton instance of theEppoClient
which makes for a generally smooth developer experience given that the Eppo SDK essentially handles dependency management for the dev. This does have its own drawbacks, but those are not particularly relevant here.There are use cases, however, when a non-singleton instance of the
EppoClient
is required. One such use case is embedding the Eppo SDK into a library which itself can be included in other applications. If that 3p library shipped with Eppo is integrated into another application that has the Eppo SDK running, there would be undefined behaviour as the SDK cannot handle this use case.The
init
method (and class constructors) forEppoClient
and subclasses have evolved organically over time, adding new options as new features are added to the clients. The very large options type is beginning to become a little untenable and disorganized so we take the opportunity to clean that up a bit here.There are other limitations and drawbacks to the current model of instantiating an
EppoClient
statically and then initializing it when the code callsinit
including the awkward coupling of needing to wait for init to resolve in order to get a reference to an initialized client. We have an opportunity to decouple initialization and waiting to make for a better DX (in addition to giving the dev full control over managing theEppoClient
reference (intrinsically allows for easier mocking in tests and will be consistent with the host applications existing DI approach).This change must be done without a major version bump and completely preserve the existing singleton API
Description
IClientConfig
name (this keeps the change backwards compatible while offering a big win in option clarity)- New method:
buildAndInit
which creates an isolated client instance.- new method:
waitForConfiguration
which resolves when the first config is loaded.How has this been documented?
How has this been tested?