-
Notifications
You must be signed in to change notification settings - Fork 19
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(core): add feature flag caching #21
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
packages/core/src/index.ts
Outdated
@@ -62,7 +68,7 @@ export class Abby< | |||
Tests extends Record<string, ABConfig> | |||
> { | |||
private log = (...args: any[]) => | |||
this.config.debug ? console.log(`core.Abby`, ...args) : () => {}; | |||
this.config.debug ? console.log(`core.Abby`, ...args) : () => { }; |
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.
do we use console
?
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.
We dont have a proper logger integrated right now , so is this used to log info in debugging mode atm.
* helper function to make testing easier | ||
*/ | ||
refetchFlags() { | ||
this.loadProjectData(); |
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.
this.loadProjectData(); | |
return this.loadProjectData(); |
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.
loadProjectData() has return type void.
packages/core/src/index.ts
Outdated
if (!flagTime) return this.#data.flags[key]; | ||
const now = new Date(); | ||
if (flagTime.getTime() <= now.getTime()) { | ||
this.refetchFlags() |
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.
this is async.. so without waiting the return down below may be old though 🤷
Co-authored-by: slaesh <[email protected]>
…tryabby/abby into feat/core/addFeatureFlagCaching
private testDevtoolOverrides: Map<keyof Tests, Tests[keyof Tests]["variants"][number]> = | ||
new Map(); | ||
|
||
private flagDevtoolOverrides: Map<FlagName, boolean> = new Map(); |
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.
guess this shouldn't be "just booleans" anymore, right?
the fix should be another PR :)
* @param key name of the featureflag | ||
* @returns value of flag | ||
*/ | ||
getValidFlag<F extends FlagName>(key: F, refetch: boolean | undefined) { |
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.
this may break every call in every lib. if this is not intended, maybe do refetch?: boolean
instead. :)
I honestly feel like this feature is kinda against our business model :D We potentially want as many requests against our API so we can charge for that. I personally think that if users want to avoid this, they can cache it themselves in memory and live with stale data |
Feature flags are cached by the core and refetched if expired.