Repository navigation
Reuse feature-flag responses across connections to the same host #630
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
vuanhphung
wants to merge
5
commits into
main
Choose a base branch
from
perf/conn-ffcache
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.
+645
−10
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5f7a754
Reuse successful feature-flag responses after access-token clients close
vuanhphung 3ce075d
Preserve header validation and verify idle reconnect behavior
vuanhphung f6abb2f
Preserve workspace-wide feature-flag sharing across idle reconnects
vuanhphung 6fe6195
Reset feature-flag refresh TTL and pin idle cache lifecycle
vuanhphung c712c07
Preserve shorter feature-flag retry windows after failed refreshes
vuanhphung 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
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,63 @@ | ||
| import { expect } from 'chai'; | ||
| import sinon from 'sinon'; | ||
| import { DBSQLClient } from '../../lib'; | ||
| import config from './utils/config'; | ||
| import FeatureFlagCache from '../../lib/FeatureFlagCache'; | ||
|
|
||
| describe('Thrift feature flags across idle reconnects', () => { | ||
| let sharedContexts: sinon.SinonStub; | ||
| let idleContexts: sinon.SinonStub; | ||
|
|
||
| beforeEach(() => { | ||
| sharedContexts = sinon.stub(FeatureFlagCache as any, 'sharedContexts').value(new Map()); | ||
| idleContexts = sinon.stub(FeatureFlagCache as any, 'idleContexts').value(new Map()); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| idleContexts.restore(); | ||
| sharedContexts.restore(); | ||
| }); | ||
|
|
||
| for (const reuseClient of [false, true]) { | ||
| it(`reuses flags and preserves results when ${ | ||
| reuseClient ? 'reconnecting a client' : 'creating another client' | ||
| }`, async () => { | ||
| const fetch = sinon.spy(FeatureFlagCache.prototype as any, 'fetchFeatureFlags'); | ||
| let client = new DBSQLClient(); | ||
| let enabled: boolean | undefined; | ||
| try { | ||
| const cycle = async (iteration: number) => { | ||
| if (!reuseClient && iteration > 0) client = new DBSQLClient(); | ||
| try { | ||
| await client.connect({ | ||
| host: config.host, | ||
| path: config.path, | ||
| token: config.token, | ||
| userAgentEntry: `feature-flag-reconnect-${reuseClient}`, | ||
| }); | ||
| if (iteration === 0) enabled = client.getTelemetryStats() !== undefined; | ||
| expect(client.getTelemetryStats() !== undefined).to.equal(enabled); | ||
| const session = await client.openSession(); | ||
| try { | ||
| const operation = await session.executeStatement('SELECT 1 AS value, CAST(NULL AS STRING) AS missing'); | ||
| try { | ||
| expect(await operation.fetchAll({ maxRows: 1 })).to.deep.equal([{ value: 1, missing: null }]); | ||
| } finally { | ||
| await operation.close(); | ||
| } | ||
| } finally { | ||
| await session.close(); | ||
| } | ||
| } finally { | ||
| await client.close(); | ||
| } | ||
| }; | ||
| await cycle(0); | ||
| await cycle(1); | ||
| expect(fetch.callCount).to.equal(1); | ||
| } finally { | ||
| fetch.restore(); | ||
| } | ||
| }); | ||
| } | ||
| }); |
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.