-
Notifications
You must be signed in to change notification settings - Fork 74
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
45
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.
+2,840
−702
Open
Add bulk evaluation #385
Changes from all commits
Commits
Show all changes
45 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 fa48aba
keep covariant
dferber90 dde2adb
adjust adapter types
dferber90 29c4f6b
Merge bulk into evaluate (#392)
dferber90 0b54172
add test
dferber90 cafd951
changesets
dferber90 e6a6157
use type import
dferber90 8559877
fix import
dferber90 7944608
extract readOverrides
dferber90 7da325c
fix import of reportValue
dferber90 d39f8f3
tracing
dferber90 8e451a9
skip bulkDecide for overwritten flags
dferber90 574ea99
update changesets
dferber90 25f6fd7
[changesets] onlyUpdatePeerDependentsWhenOutOfRange
dferber90 14fcc20
add type guard
dferber90 7da30f5
Reapply "Add oidc support (#374)" (#389)
luismeyer 6180dbf
bump oidc package
luismeyer 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,5 @@ | ||
| --- | ||
| '@flags-sdk/vercel': minor | ||
| --- | ||
|
|
||
| Reduces overhead when evaluating multiple flags via `evaluate()` or `precompute()` by using new bulk evaluation capabilities of `@vercel/flags-core`. |
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
| 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,24 @@ | ||
| --- | ||
| 'flags': minor | ||
| --- | ||
|
|
||
| Introduces a new bulk evaluation method for adapters, which is used when multiple flags are evaluated together to avoid making individual calls to each adapter. | ||
|
|
||
| When applications call `evaluate()` or `precompute()` function from `flags/next` it now defers bulk evaluation to the underlying adapters in case those support it, or otherwise falls back to evaluating each flag individually. | ||
|
|
||
| This speeds up evaluation for applications that need to evaluate multiple flags at once, as the runtime needs to handle fewer promises and more work is reused. In testing we have seen a 20x improvement when called with 100 flags. | ||
|
|
||
| ```tsx | ||
| import { evaluate } from 'flags/next'; | ||
| import { flagA, flagB } from '../flags'; | ||
|
|
||
| // pass a list of flags | ||
| const [valueA, valueB] = await evaluate([flagA, flagB]); | ||
|
|
||
| // pass an object | ||
| const { a, b } = await evaluate({ a: flagA, b: flagB }); | ||
| ``` | ||
|
|
||
| Adapters can opt into bulk evaluation by implementing a `bulkDecide` method and setting a stable `adapterId`. When both are present, flag evaluation 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 still resolve through the normal per-flag path inside `evaluate()` and still benefit from now reusing the shared per-request headers, cookies, and overrides reads. | ||
|
|
||
| Tracing reflects this grouping. `evaluate()` (and therefore `precompute()`) now emits an `evaluate` span carrying a `flagCount` attribute. Within it, bulk-evaluated flags no longer emit an individual per-flag `run` span; instead each adapter group emits a single `batch` span (carrying the `adapterId`, the `keys` evaluated in the batch, and `cachedCount`/`overrideCount`/`decidedCount` attributes summarizing how the batch resolved) so per-flag instrumentation overhead is not reintroduced. Flags that fall back to the per-flag path continue to emit their own `flag` span as before. |
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,13 @@ | ||
| --- | ||
| "@flags-sdk/vercel": minor | ||
| "@vercel/prepare-flags-definitions": minor | ||
| "@vercel/flags-core": minor | ||
| --- | ||
|
|
||
| Add OIDC authentication support for Vercel Flags clients and generated flag definitions. | ||
|
|
||
| `@vercel/flags-core` can now create clients without an SDK key and authenticate with a Vercel OIDC token, while still supporting SDK keys and connection strings. Bundled definitions can be looked up by SDK key hash or OIDC project ID. | ||
|
|
||
| `@vercel/prepare-flags-definitions` now collects both SDK keys and `VERCEL_OIDC_TOKEN`, fetches definitions for each auth entry, deduplicates identical definitions across SDK keys and OIDC project IDs, and writes generated maps keyed by SDK key hash or project ID. | ||
|
|
||
| `@flags-sdk/vercel` now supports provider data lookup for Vercel flag origins that do not include an SDK key, allowing OIDC-backed clients to resolve project metadata. |
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
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.