Add enhanced feature flag import support - #26
Christine Wanjau (ChristineWanjau) wants to merge 9 commits into
Conversation
6f8dc19 to
faa2265
Compare
…pping, stream kvset guard - Add ReadableStreamFeatureFlagSource and FileFeatureFlagSource specs with ffset/default fixtures - Fix StringFeatureFlagSource.setFilterOptions to use FfSet (not dead KvSet branch) for wildcard filters - Map MS FM allocation to camelCase in DefaultFeatureFlagsConverter - Reject KvSet at construction in ReadableStreamFeatureFlagSource
Resolves eslint indent errors in readableStreamFeatureFlagSource and stringFeatureFlagSource.
Use sinon .rejects() and await the server-error import so a synchronous throw no longer escapes AdaptiveTaskManager and surfaces as an uncaught rejection in later tests (ERR_MOCHA_MULTIPLE_DONE).
| * @param options - Import options including timeout, progress callback, strict mode, and import mode. | ||
| * @returns Promise<void> | ||
| */ | ||
| public async Import(featureFlagSource: FeatureFlagSource, options: FeatureFlagImportOptions): Promise<void> { |
There was a problem hiding this comment.
| public async Import(featureFlagSource: FeatureFlagSource, options: FeatureFlagImportOptions): Promise<void> { | |
| public async Import(featureFlagsSource: FeatureFlagSource, options: FeatureFlagImportOptions): Promise<void> { |
There was a problem hiding this comment.
Updated
| * | ||
| * @returns Collection of FeatureFlagParam or FeatureFlagChange objects. | ||
| */ | ||
| GetFeatureFlags(): Promise<FeatureFlagParam[] | FeatureFlagChange[]>; |
There was a problem hiding this comment.
In the configuration setting path the name is SetConfigurationSettingParam. What is the reason for the different pattern here?
| /** @internal */ | ||
| export function getSettingIdentity(nameOrKey: string, label?: string): string { | ||
| return `${nameOrKey}\u0000${label ?? ""}`; | ||
| } |
There was a problem hiding this comment.
Should just be private helper in the respective importer. No need to generalize cross name and key.
There was a problem hiding this comment.
Sure. Updated
| /** @internal */ | ||
| export function validateImportMode(importMode: ImportMode): void { | ||
| if (importMode !== ImportMode.IgnoreMatch && importMode !== ImportMode.All) { | ||
| throw new ArgumentError("Only options supported for Import Mode are 'All' and 'Ignore-Match'."); | ||
| } | ||
| } |
There was a problem hiding this comment.
This should be in a helper named validation.ts
There was a problem hiding this comment.
Added validation.ts
| /** @internal */ | ||
| export function createAdaptiveTaskManager<TValue, TResult>( | ||
| task: (value: TValue) => Promise<TResult>, | ||
| values: TValue[] | ||
| ): AdaptiveTaskManager<TResult> { | ||
| let index = 0; | ||
| return new AdaptiveTaskManager(() => { | ||
| if (index === values.length) { | ||
| return undefined; | ||
| } | ||
| const value = values[index++]; | ||
| return () => task(value); | ||
| }, values.length); | ||
| } | ||
|
|
||
| /** @internal */ | ||
| export async function executeTasksWithTimeout<T>( | ||
| taskManager: AdaptiveTaskManager<T>, | ||
| timeInSeconds: number, | ||
| callback?: (progress: ImportProgress) => unknown | ||
| ): Promise<void> { | ||
| let timer: NodeJS.Timeout; | ||
| const timeoutPromise = new Promise((_, reject) => { | ||
| timer = setTimeout(() => reject(new OperationTimeoutError()), timeInSeconds * 1000); | ||
| }); | ||
| await Promise.race([taskManager.Start(callback), timeoutPromise]).finally(() => clearTimeout(timer)); | ||
| } |
There was a problem hiding this comment.
TaskManagement.ts
There was a problem hiding this comment.
Added TaskManagement.ts
| } | ||
|
|
||
| /** @internal */ | ||
| export function isChangeArray<TChange>(value: unknown): value is TChange[] { |
There was a problem hiding this comment.
Can we use Any instead? Looks like a type that exists somewhere when TChange is used.
There was a problem hiding this comment.
Yes. Updated
Summary
FeatureFlagImporterusingFeatureFlagClientfrom@azure/app-configuration1.13.0-beta.1appconfig/ffsetserialized feature flag sources with rootprofiledetectionprofile: appconfig/kvsetfor KVSet documents and add FFSet validation and design documentation