-
Notifications
You must be signed in to change notification settings - Fork 11
load feature flags from new endpoint #341
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
linglingye001
wants to merge
16
commits into
preview
Choose a base branch
from
linglingye/load-new-flag
base: preview
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
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1650684
load enhanced feature flags
linglingye001 42c37a0
fix tests
linglingye001 b7dc2f9
track whether enhanced feature flags were loaded
linglingye001 0ff2561
rename new feature flags to 'enhanced*', drop 'classic' for old featu…
linglingye001 376ce71
fix filter parameter handling
linglingye001 f62bc58
resolve comments
linglingye001 0c777d8
update
linglingye001 f079b3e
resolve comments
linglingye001 4ce3f15
Merge branch 'preview' of https://github.com/Azure/AppConfiguration-J…
linglingye001 b50daed
enhanced ff: remove prefix in feature flag reference and update clien…
linglingye001 e5c0dd7
update enhanced ff filter parameter handling with classic
linglingye001 a80420f
enhanced ff filter parameter: preserve fallback to string
linglingye001 a3d712e
add null/undefined check for filter parameters
linglingye001 9d0c7ec
add api version validation
linglingye001 66bbaa0
update dependency version
linglingye001 558306a
fix lint
linglingye001 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,98 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import { | ||
| AppConfigurationClient as ConfigurationClient, | ||
| AppConfigurationClientOptions as ConfigurationClientOptions, | ||
| CheckConfigurationSettingsOptions, | ||
| ConfigurationSettingId, | ||
| FeatureFlagClient, | ||
| FeatureFlagClientOptions, | ||
| GetConfigurationSettingOptions, | ||
| GetSnapshotOptions, | ||
| KnownAppConfigurationApiVersion, | ||
| ListConfigurationSettingsForSnapshotOptions, | ||
| ListConfigurationSettingsOptions, | ||
| ListFeatureFlagsOptions | ||
| } from "@azure/app-configuration"; | ||
| import { TokenCredential } from "@azure/identity"; | ||
| import { instanceOfTokenCredential } from "./common/utils.js"; | ||
| import { ArgumentError } from "./common/errors.js"; | ||
| import { ErrorMessages } from "./common/errorMessages.js"; | ||
| import { RequestTracingOptions, applyRequestTracing } from "./requestTracing/utils.js"; | ||
|
|
||
| /** | ||
| * A client for the operations the provider needs from both the @see ConfigurationClient and | ||
| * @see FeatureFlagClient SDK clients. Request tracing is applied before delegating each operation. | ||
| */ | ||
| export class AppConfigurationClient { | ||
| #configurationClient: ConfigurationClient; | ||
| #featureFlagClient: FeatureFlagClient; | ||
|
|
||
| constructor(connectionString: string, options?: ConfigurationClientOptions); | ||
| constructor(endpoint: string, credential: TokenCredential, options?: ConfigurationClientOptions); | ||
| constructor( | ||
| connectionStringOrEndpoint: string, | ||
| credentialOrOptions?: TokenCredential | ConfigurationClientOptions, | ||
| options?: ConfigurationClientOptions | ||
| ) { | ||
| const credentialPassed = instanceOfTokenCredential(credentialOrOptions); | ||
| const configurationClientOptions = credentialPassed | ||
| ? options | ||
| : credentialOrOptions as ConfigurationClientOptions | undefined; | ||
| const featureFlagClientOptions = getFeatureFlagClientOptions(configurationClientOptions); | ||
|
|
||
| if (credentialPassed) { | ||
| const credential = credentialOrOptions as TokenCredential; | ||
| this.#configurationClient = new ConfigurationClient(connectionStringOrEndpoint, credential, configurationClientOptions); | ||
| this.#featureFlagClient = new FeatureFlagClient(connectionStringOrEndpoint, credential, featureFlagClientOptions); | ||
| } else { | ||
| this.#configurationClient = new ConfigurationClient(connectionStringOrEndpoint, configurationClientOptions); | ||
| this.#featureFlagClient = new FeatureFlagClient(connectionStringOrEndpoint, featureFlagClientOptions); | ||
| } | ||
| } | ||
|
|
||
| listConfigurationSettings(listOptions: ListConfigurationSettingsOptions, tracingOptions: RequestTracingOptions) { | ||
| return this.#configurationClient.listConfigurationSettings(applyRequestTracing(tracingOptions, listOptions)); | ||
| } | ||
|
|
||
| checkConfigurationSettings(checkOptions: CheckConfigurationSettingsOptions, tracingOptions: RequestTracingOptions) { | ||
| return this.#configurationClient.checkConfigurationSettings(applyRequestTracing(tracingOptions, checkOptions)); | ||
| } | ||
|
|
||
| getConfigurationSetting(configurationSettingId: ConfigurationSettingId, getOptions: GetConfigurationSettingOptions | undefined, tracingOptions: RequestTracingOptions) { | ||
| return this.#configurationClient.getConfigurationSetting(configurationSettingId, applyRequestTracing(tracingOptions, getOptions)); | ||
| } | ||
|
|
||
| getSnapshot(snapshotName: string, getOptions: GetSnapshotOptions | undefined, tracingOptions: RequestTracingOptions) { | ||
| return this.#configurationClient.getSnapshot(snapshotName, applyRequestTracing(tracingOptions, getOptions)); | ||
| } | ||
|
|
||
| listConfigurationSettingsForSnapshot(snapshotName: string, listOptions: ListConfigurationSettingsForSnapshotOptions | undefined, tracingOptions: RequestTracingOptions) { | ||
| return this.#configurationClient.listConfigurationSettingsForSnapshot(snapshotName, applyRequestTracing(tracingOptions, listOptions)); | ||
| } | ||
|
|
||
| listFeatureFlags(listOptions: ListFeatureFlagsOptions, tracingOptions: RequestTracingOptions) { | ||
| return this.#featureFlagClient.listFeatureFlags(applyRequestTracing(tracingOptions, listOptions)); | ||
| } | ||
| } | ||
|
|
||
| export function getFeatureFlagClientOptions(options?: ConfigurationClientOptions): FeatureFlagClientOptions | undefined { | ||
| if (options === undefined) { | ||
| return undefined; | ||
| } | ||
| if (options.apiVersion !== undefined && | ||
| options.apiVersion !== KnownAppConfigurationApiVersion.V20260501Preview) { | ||
| throw new ArgumentError(ErrorMessages.API_VERSION_NOT_SUPPORTED); | ||
| } | ||
|
|
||
| return { | ||
| ...options, | ||
| ...(options.retryOptions && { retryOptions: { ...options.retryOptions } }), | ||
| ...(options.proxyOptions && { proxyOptions: { ...options.proxyOptions } }), | ||
| ...(options.tlsOptions && { tlsOptions: { ...options.tlsOptions } }), | ||
| ...(options.userAgentOptions && { userAgentOptions: { ...options.userAgentOptions } }), | ||
| ...(options.telemetryOptions && { telemetryOptions: { ...options.telemetryOptions } }), | ||
| ...(options.additionalPolicies && { additionalPolicies: [...options.additionalPolicies] }) | ||
| }; | ||
| } | ||
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
4 changes: 2 additions & 2 deletions
4
src/configurationClientWrapper.ts → src/appConfigurationClientWrapper.ts
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.