-
Notifications
You must be signed in to change notification settings - Fork 72
Add bulk evaluation #385
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
Open
dferber90
wants to merge
29
commits into
main
Choose a base branch
from
bulk
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add bulk evaluation #385
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
bb72353
[flags] avoid re-imports
dferber90 ecfcc32
[flags] avoid iife microtask queue overhead
dferber90 df5281a
[flags] skip awaits where possible
dferber90 f693413
[flags] allow bulk eval
dferber90 fe9605a
wip
dferber90 099fda8
add bulk mode to playground
dferber90 aa0dfba
first try of bulk eval
dferber90 7cb1aeb
add bulk evaluation to adapters
dferber90 3af7129
Merge branch 'main' into bulk
dferber90 ea6d164
reuse
dferber90 cb04cde
simplify
dferber90 7fd2e5e
versions
dferber90 6321ab5
Merge branch 'main' into bulk
dferber90 e475198
rm outdated changeset
dferber90 2e1b113
rm outdated changeset
dferber90 930a9e0
revert playground
dferber90 35e518b
revert playground flags
dferber90 e076dd0
rm logs
dferber90 7a6c28d
reuse cache of resolved flags for bulk
dferber90 a576379
simplify
dferber90 5b2dc37
changesets
dferber90 380d725
support bulk([]) and bulk({})
dferber90 66b3a23
flagKey → key
dferber90 bf80336
allow any type in expectPermutations
dferber90 c65406b
avoid unnecessary mapping
dferber90 9575a4a
fix changeset
dferber90 254480e
validate package.json fields
dferber90 2225248
update package.json fields
dferber90 581a9c5
Merge branch 'main' into bulk
dferber90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| '@flags-sdk/vercel': minor | ||
| --- | ||
|
|
||
| Faster evaluation of flags when using the Vercel adapter via `bulk()`. | ||
|
|
||
| This version of `flags-sdk/vercel` implements `bulkDecide` on the Vercel Flags adapter so flags can be evaluated together via `bulk()` from `flags/next`. | ||
|
|
||
| This improves performance by avoiding the per-flag overhead of separate `evaluate()` calls. We've seen a 10x improvement in evaluation time for large batches of flags. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| --- | ||
| '@vercel/flags-core': minor | ||
| --- | ||
|
|
||
| Add `bulkEvaluate` method to `FlagsClient` for resolving multiple flags against shared entities in a single call. | ||
|
|
||
| ```ts | ||
| const results = await client.bulkEvaluate( | ||
| [ | ||
| { key: 'a', defaultValue: false }, | ||
| { key: 'b', defaultValue: 'off' }, | ||
| ], | ||
| entities, | ||
| ); | ||
|
|
||
| results.a; // EvaluationResult<boolean> | ||
| results.b; // EvaluationResult<string> | ||
| ``` | ||
|
|
||
| Avoids the per-flag overhead of separate `evaluate()` calls — the datafile is read once, entities are resolved once, and all flags share the same environment/segments lookup. Each entry in the returned record is a full `EvaluationResult` with `value`, `reason`, `outcomeType`, and `metrics`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| 'flags': minor | ||
| --- | ||
|
|
||
| Add `bulk()` function for evaluating multiple flags in a single call from the `flags/next` entry point. | ||
|
|
||
| ```tsx | ||
| import { bulk } from 'flags/next'; | ||
| import { flagA, flagB } from '../flags'; | ||
|
|
||
| // pass a list of flags | ||
| const [valueA, valueB] = await bulk([flagA, flagB]); | ||
|
|
||
| // pass an object | ||
| const { a, b } = await bulk({ a: flagA, b: flagB }); | ||
| ``` | ||
|
|
||
| Adapters can now opt into batched evaluation by implementing an optional `bulkDecide` method and setting a stable `adapterId`. When both are present, `bulk()` groups flags that share the same `adapterId` and `identify` source and invokes `bulkDecide` once per group instead of calling `decide` per flag. Flags without a bulk-capable adapter (or with an inline `decide`) still resolve through the normal per-flag path inside `bulk()` and benefit from the shared per-request headers, cookies, and overrides reads. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.