Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 51 additions & 47 deletions assets/featureFlag/alpha.json
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
{
"version": 1,
"description": "Feature flags for alpha environment",
"features": {
"Constants": {
"enabled": false
},
"EnhancedDryRun": {
"enabled": true,
"fleetPercentage": 100,
"allowlistedRegions": [
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"ca-central-1",
"ca-west-1",
"sa-east-1",
"mx-central-1",
"eu-north-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"eu-central-1",
"eu-central-2",
"eu-south-1",
"eu-south-2",
"ap-east-1",
"ap-east-2",
"ap-south-1",
"ap-south-2",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-southeast-1",
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ap-southeast-7",
"me-south-1",
"me-central-1",
"af-south-1",
"il-central-1",
"test-region"
]
"version": 1,
"description": "Feature flags for alpha environment",
"features": {
"Constants": {
"enabled": false
},
"EnhancedDryRun": {
"enabled": true,
"fleetPercentage": 100,
"allowlistedRegions": [
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"ca-central-1",
"ca-west-1",
"sa-east-1",
"mx-central-1",
"eu-north-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"eu-central-1",
"eu-central-2",
"eu-south-1",
"eu-south-2",
"ap-east-1",
"ap-east-2",
"ap-south-1",
"ap-south-2",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-southeast-1",
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ap-southeast-7",
"me-south-1",
"me-central-1",
"af-south-1",
"il-central-1",
"test-region"
]
},
"FileDb": {
"enabled": true,
"fleetPercentage": 100
}
}
}
}
}
96 changes: 50 additions & 46 deletions assets/featureFlag/beta.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,52 @@
{
"version": 1,
"description": "Feature flags for beta environment",
"features": {
"Constants": {
"enabled": false
},
"EnhancedDryRun": {
"enabled": true,
"fleetPercentage": 100,
"allowlistedRegions": [
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"ca-central-1",
"ca-west-1",
"sa-east-1",
"mx-central-1",
"eu-north-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"eu-central-1",
"eu-central-2",
"eu-south-1",
"eu-south-2",
"ap-east-1",
"ap-east-2",
"ap-south-1",
"ap-south-2",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-southeast-1",
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ap-southeast-7",
"me-south-1",
"me-central-1",
"af-south-1",
"il-central-1"
]
"version": 1,
"description": "Feature flags for beta environment",
"features": {
"Constants": {
"enabled": false
},
"EnhancedDryRun": {
"enabled": true,
"fleetPercentage": 100,
"allowlistedRegions": [
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"ca-central-1",
"ca-west-1",
"sa-east-1",
"mx-central-1",
"eu-north-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"eu-central-1",
"eu-central-2",
"eu-south-1",
"eu-south-2",
"ap-east-1",
"ap-east-2",
"ap-south-1",
"ap-south-2",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-southeast-1",
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ap-southeast-7",
"me-south-1",
"me-central-1",
"af-south-1",
"il-central-1"
]
},
"FileDb": {
"enabled": false,
"fleetPercentage": 100
}
}
}
}
}
96 changes: 50 additions & 46 deletions assets/featureFlag/prod.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,52 @@
{
"version": 1,
"description": "Feature flags for prod environment",
"features": {
"Constants": {
"enabled": false
},
"EnhancedDryRun": {
"enabled": true,
"fleetPercentage": 100,
"allowlistedRegions": [
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"ca-central-1",
"ca-west-1",
"sa-east-1",
"mx-central-1",
"eu-north-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"eu-central-1",
"eu-central-2",
"eu-south-1",
"eu-south-2",
"ap-east-1",
"ap-east-2",
"ap-south-1",
"ap-south-2",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-southeast-1",
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ap-southeast-7",
"me-south-1",
"me-central-1",
"af-south-1",
"il-central-1"
]
"version": 1,
"description": "Feature flags for prod environment",
"features": {
"Constants": {
"enabled": false
},
"EnhancedDryRun": {
"enabled": true,
"fleetPercentage": 100,
"allowlistedRegions": [
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"ca-central-1",
"ca-west-1",
"sa-east-1",
"mx-central-1",
"eu-north-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"eu-central-1",
"eu-central-2",
"eu-south-1",
"eu-south-2",
"ap-east-1",
"ap-east-2",
"ap-south-1",
"ap-south-2",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-southeast-1",
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ap-southeast-7",
"me-south-1",
"me-central-1",
"af-south-1",
"il-central-1"
]
},
"FileDb": {
"enabled": false,
"fleetPercentage": 0
}
}
}
}
}
5 changes: 3 additions & 2 deletions src/datastore/DataStore.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { FeatureFlag } from '../featureFlag/FeatureFlagI';
import { Closeable } from '../utils/Closeable';
import { isWindows } from '../utils/Environment';
import { pathToStorage } from '../utils/Storage';
Expand Down Expand Up @@ -62,8 +63,8 @@ export class MultiDataStoreFactoryProvider implements DataStoreFactoryProvider {
private readonly memoryStoreFactory: MemoryStoreFactory;
private readonly persistedStore: DataStoreFactory;

constructor() {
if (isWindows) {
constructor(fileDbFeatureFlag: FeatureFlag) {
if (fileDbFeatureFlag.isEnabled() || isWindows) {
this.persistedStore = new FileStoreFactory(pathToStorage());
} else {
this.persistedStore = new LMDBStoreFactory(pathToStorage());
Expand Down
2 changes: 1 addition & 1 deletion src/featureFlag/DynamicFeatureFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Closeable } from '../utils/Closeable';
import { FeatureFlagBuilderType, FeatureFlagConfigType, TargetedFeatureFlagBuilderType } from './FeatureFlagBuilder';
import { FeatureFlag, TargetedFeatureFlag } from './FeatureFlagI';

export const DynamicRefreshIntervalMs = 60 * 1000;
export const DynamicRefreshIntervalMs = 2 * 60 * 1000;

export class DynamicFeatureFlag implements FeatureFlag, Closeable {
private flag: FeatureFlag;
Expand Down
9 changes: 7 additions & 2 deletions src/featureFlag/FeatureFlagProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { FeatureFlagSupplier, FeatureFlagConfigKey, TargetedFeatureFlagConfigKey

const log = LoggerFactory.getLogger('FeatureFlagProvider');

const RefreshIntervalMs = 5 * 60 * 1000;
const RefreshIntervalMs = 15 * 60 * 1000;

export class FeatureFlagProvider implements Closeable {
@Telemetry()
Expand All @@ -28,7 +28,7 @@ export class FeatureFlagProvider implements Closeable {

constructor(
private readonly getLatestFeatureFlags: (env: string) => Promise<unknown>,
private readonly localFile = join(__dirname, 'assets', 'featureFlag', `${AwsEnv.toLowerCase()}.json`),
private readonly localFile = featureFlagLocalFile(),
refreshIntervalMs: number = RefreshIntervalMs,
dynamicRefreshIntervalMs: number = DynamicRefreshIntervalMs,
) {
Expand Down Expand Up @@ -78,6 +78,7 @@ export class FeatureFlagProvider implements Closeable {
this.config = newConfig;
writeFileSync(this.localFile, JSON.stringify(newConfig, undefined, 2));
this.telemetry.count('refresh.local.update', 1);
log.info('Updated and saved feature flags');
this.log();
}

Expand Down Expand Up @@ -135,3 +136,7 @@ function defaultConfig(configFile: string, telemetry: ScopedTelemetry): FeatureF
return { version: 1, description: 'Default empty config', features: {} };
}
}

export function featureFlagLocalFile(baseDir: string = __dirname) {
return join(baseDir, 'assets', 'featureFlag', `${AwsEnv.toLowerCase()}.json`);
}
Loading
Loading