Skip to content
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

Provide a customer persistence store (FF-2085) #65

Merged
merged 5 commits into from
May 16, 2024

Conversation

leoromanovsky
Copy link
Member


labels: mergeable

Fixes: #issue

Motivation and Context

Allow customers to provide a customer persistence store implementation of IAsyncStore. They can pair this with (#64) to create an "off-line" mode where the client CDN will not make any remote requests. In this case they would provide a IAsyncStore that reads from a local file (or memory) for a configuration that was provided by their server.

Another use case is for AWS Lambda functions, not in scope for this PR as that is nodejs, which are very short-lived servers. Their persistence store can be backed by DynamoDB to avoid many CDN requests.

Description

  • adds configuration parameter for persistenceStore - if provided a HybridConfigurationStore will be created with it

questions for reviewers

In order to provide the persistence store, I needed to instantiate the Client singleton within the init method. Does this seem like an acceptable compromise? The alternative is adding a usePersistenceStore() method onto js-commons.

How has this been tested?

Copy link
Contributor

@aarsilv aarsilv left a comment

Choose a reason for hiding this comment

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

❤️

export function configurationStorageFactory(): IConfigurationStore<Flag> {
if (hasWindowLocalStorage()) {
export function configurationStorageFactory(
persistenceStore?: IAsyncStore<Flag>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider renaming to persistentStore, which I think is what this is usually called, unless I'm misunderstanding what this is

Copy link
Contributor

Choose a reason for hiding this comment

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

And I think it makes sense as an argument in init rather than a usePersistentStore(store) method that could modify the client's storage after it has been initialized. If there's a scenario where swapping stores is useful, it doesn't seem like we're blocked from providing that method in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

And I think it makes sense as an argument in init rather than a usePersistentStore(store) method that could modify the client's storage after it has been initialized

That was my thinking too - can't imagine wanting to swap this out in the middle of a session.

Base automatically changed from lr/ff-1980/no-init2 to main May 16, 2024 22:35
@leoromanovsky leoromanovsky merged commit b76e8d8 into main May 16, 2024
2 checks passed
@leoromanovsky leoromanovsky deleted the lr/ff-2085/custom branch May 16, 2024 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants