Skip to content

Commit

Permalink
feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Emanuele De Cupis authored and Emanuele De Cupis committed Jul 24, 2020
1 parent fd190d5 commit 2c212b9
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
7 changes: 5 additions & 2 deletions UserDataProcessingTrigger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
trackUserDataDeleteEvent,
trackUserDataDownloadEvent
} from "../utils/appinsightsEvents";
import { flags } from "../utils/featureFlags";

const logPrefix = "UserDataProcessingTrigger";

Expand Down Expand Up @@ -84,7 +85,8 @@ export function index(
.decode(processableOrNot)
.chain(processable =>
fromNullable(undefined)(
ProcessableUserDataDownload.is(processable)
flags.ENABLE_USER_DATA_DOWNLOAD &&
ProcessableUserDataDownload.is(processable)
? () => {
context.log.info(
`${logPrefix}: starting UserDataDownloadOrchestrator with ${processable.fiscalCode}`
Expand All @@ -96,7 +98,8 @@ export function index(
processable
);
}
: ProcessableUserDataDelete.is(processable)
: flags.ENABLE_USER_DATA_DELETE &&
ProcessableUserDataDelete.is(processable)
? () => {
context.log.info(
`${logPrefix}: starting UserDataDeleteOrchestrator with ${processable.fiscalCode}`
Expand Down
27 changes: 27 additions & 0 deletions __local.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "node",
"FUNCTIONS_V2_COMPATIBILITY_MODE": false,
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=fnadmintest;AccountKey=7ykAEykBK3n5De9OecfSckqYDQf7MbUISmAD9A4h1RpDqFmIOOBfGKmCtw0kjAbdkPD2fslmwzrMSfw9dcN/+w==;EndpointSuffix=core.windows.net;",
"MESSAGE_CONTAINER_NAME": "message-content",
"PUBLIC_API_URL": "https://api.io.italia.it",
"PUBLIC_API_KEY": "12345",
"COSMOSDB_URI": "https://io-d-cosmos-free.documents.azure.com:443/",
"COSMOSDB_KEY": "g2ZjO2b2NUo4wFX8G848WkZmNeEKHB55pONQj4LuTFgoT5km7SYlFvwMDxLClOIFMLRvoOaStCV26PaiISwfkw==",
"COSMOSDB_NAME": "emanuele",
"COSMOSDB_CONNECTION_STRING": "AccountEndpoint=https://io-d-cosmos-free.documents.azure.com:443/;AccountKey=g2ZjO2b2NUo4wFX8G848WkZmNeEKHB55pONQj4LuTFgoT5km7SYlFvwMDxLClOIFMLRvoOaStCV26PaiISwfkw==;",
"USER_DATA_CONTAINER_NAME": "user-data-download",
"USER_DATA_BACKUP_CONTAINER_NAME": "user-data-backup",
"PUBLIC_DOWNLOAD_BASE_URL": "https://<STORAGE BASE NAME>.blob.core.windows.net/user-data-download",
"AzureWebJobsStorageConnection": "DefaultEndpointsProtocol=https;AccountName=fnadmintest;AccountKey=7ykAEykBK3n5De9OecfSckqYDQf7MbUISmAD9A4h1RpDqFmIOOBfGKmCtw0kjAbdkPD2fslmwzrMSfw9dcN/+w==;EndpointSuffix=core.windows.net;",
"UserDataArchiveStorageConnection": "DefaultEndpointsProtocol=https;AccountName=fnadmintest;AccountKey=7ykAEykBK3n5De9OecfSckqYDQf7MbUISmAD9A4h1RpDqFmIOOBfGKmCtw0kjAbdkPD2fslmwzrMSfw9dcN/+w==;EndpointSuffix=core.windows.net;",
"UserDataBackupStorageConnection": "$DefaultEndpointsProtocol=https;AccountName=fnadmintest;AccountKey=7ykAEykBK3n5De9OecfSckqYDQf7MbUISmAD9A4h1RpDqFmIOOBfGKmCtw0kjAbdkPD2fslmwzrMSfw9dcN/+w==;EndpointSuffix=core.windows.net;",
"MessageContentStorageConnection": "DefaultEndpointsProtocol=https;AccountName=fnadmintest;AccountKey=7ykAEykBK3n5De9OecfSckqYDQf7MbUISmAD9A4h1RpDqFmIOOBfGKmCtw0kjAbdkPD2fslmwzrMSfw9dcN/+w==;EndpointSuffix=core.windows.net;",
"REDIS_URL": "localhost",
"REDIS_PORT": 6379,
"REDIS_PASSWORD": "xxxx",
"NODE_ENV": "production",
"USER_DATA_DOWNLOAD_DELAY_HOURS": 0
}
}
24 changes: 24 additions & 0 deletions utils/featureFlags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
*
*/

import { fromNullable } from "fp-ts/lib/Option";
import * as t from "io-ts";

const getEnvVariable = (decoder: t.Mixed) => (
name: string,
defaultValue: typeof decoder["_A"]
) =>
fromNullable(process.env[name])
.map(decoder.decode)
.getOrElse(defaultValue);

const getFlagFromEnv = getEnvVariable(t.boolean);

export const flags = {
ENABLE_USER_DATA_DELETE: getFlagFromEnv("FF_ENABLE_USER_DATA_DELETE", true),
ENABLE_USER_DATA_DOWNLOAD: getFlagFromEnv(
"FF_ENABLE_USER_DATA_DOWNLOAD",
true
)
};

0 comments on commit 2c212b9

Please sign in to comment.