Skip to content
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

Refactor storage configuration #170

Merged
merged 1 commit into from
Nov 18, 2021
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
4 changes: 3 additions & 1 deletion GetMessage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ const notificationStatusModel = new NotificationStatusModel(
cosmosdbInstance.container(NOTIFICATION_STATUS_COLLECTION_NAME)
);

const blobService = createBlobService(config.QueueStorageConnection);
const blobService = createBlobService(
config.MESSAGE_CONTENT_STORAGE_CONNECTION_STRING
);

app.get(
"/api/v1/messages/:fiscalcode/:id",
Expand Down
4 changes: 3 additions & 1 deletion GetSubscriptionsFeed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ const serviceModel = new ServiceModel(
cosmosdbInstance.container(SERVICE_COLLECTION_NAME)
);

const tableService = createTableService(config.QueueStorageConnection);
const tableService = createTableService(
config.SUBSCRIPTION_FEED_STORAGE_CONNECTION_STRING
);

app.get(
"/api/v1/subscriptions-feed/:date",
Expand Down
13 changes: 12 additions & 1 deletion Info/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,18 @@ export function Info(): express.RequestHandler {
const handler = InfoHandler(
healthcheck.checkApplicationHealth(IConfig, [
c => healthcheck.checkAzureCosmosDbHealth(c.COSMOSDB_URI, c.COSMOSDB_KEY),
c => healthcheck.checkAzureStorageHealth(c.QueueStorageConnection),
c =>
healthcheck.checkAzureStorageHealth(
c.MESSAGE_CONTENT_STORAGE_CONNECTION_STRING
),
c =>
healthcheck.checkAzureStorageHealth(
c.SUBSCRIPTION_FEED_STORAGE_CONNECTION_STRING
),
c =>
healthcheck.checkAzureStorageHealth(
c.INTERNAL_STORAGE_CONNECTION_STRING
),
c => healthcheck.checkUrlHealth(c.WEBHOOK_CHANNEL_URL)
])
);
Expand Down
12 changes: 9 additions & 3 deletions ProcessMessage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ const messageModel = new MessageModel(
config.MESSAGE_CONTAINER_NAME
);

const blobService = createBlobService(config.QueueStorageConnection);
const blobServiceForMessageContent = createBlobService(
config.MESSAGE_CONTENT_STORAGE_CONNECTION_STRING
);

const blobServiceForTemporaryProcessingMessage = createBlobService(
config.INTERNAL_STORAGE_CONNECTION_STRING
);

const servicePreferencesModel = new ServicesPreferencesModel(
cosmosdbInstance.container(SERVICE_PREFERENCES_COLLECTION_NAME),
Expand All @@ -52,13 +58,13 @@ const telemetryClient = initTelemetryClient(

const retrieveProcessingMessageData = makeRetrieveExpandedDataFromBlob(
CommonMessageData,
blobService,
blobServiceForTemporaryProcessingMessage,
config.PROCESSING_MESSAGE_CONTAINER_NAME
);

const activityFunctionHandler: AzureFunction = getProcessMessageHandler({
isOptInEmailEnabled: config.FF_OPT_IN_EMAIL_ENABLED,
lBlobService: blobService,
lBlobService: blobServiceForMessageContent,
lMessageModel: messageModel,
lMessageStatusModel: messageStatusModel,
lProfileModel: profileModel,
Expand Down
4 changes: 3 additions & 1 deletion StoreMessageContentActivity/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ const messageModel = new MessageModel(
config.MESSAGE_CONTAINER_NAME
);

const blobService = createBlobService(config.QueueStorageConnection);
const blobService = createBlobService(
config.MESSAGE_CONTENT_STORAGE_CONNECTION_STRING
);

const servicePreferencesModel = new ServicesPreferencesModel(
cosmosdbInstance.container(SERVICE_PREFERENCES_COLLECTION_NAME),
Expand Down
19 changes: 15 additions & 4 deletions utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { NumberFromString } from "@pagopa/ts-commons/lib/numbers";
import { pipe } from "fp-ts/lib/function";
import { CommaSeparatedListOf } from "./comma-separated-list";

// used for internal job dispatch, temporary files, etc...
const InternalStorageAccount = t.interface({
INTERNAL_STORAGE_CONNECTION_STRING: NonEmptyString,
// queues for handling message processing jobs
Expand All @@ -28,6 +29,18 @@ const InternalStorageAccount = t.interface({
PROCESSING_MESSAGE_CONTAINER_NAME: NonEmptyString
});

// used to read and write message content on blob storage
const MessageContentStorageAccount = t.interface({
MESSAGE_CONTAINER_NAME: NonEmptyString,
MESSAGE_CONTENT_STORAGE_CONNECTION_STRING: NonEmptyString
});

// used to read and write subscription feed entries on table storage
const SubscriptionFeedStorageAccount = t.interface({
SUBSCRIPTIONS_FEED_TABLE: NonEmptyString,
SUBSCRIPTION_FEED_STORAGE_CONNECTION_STRING: NonEmptyString
});

// global app configuration
export type IConfig = t.TypeOf<typeof IConfig>;
export const IConfig = t.intersection([
Expand All @@ -47,13 +60,9 @@ export const IConfig = t.intersection([
IO_FUNCTIONS_ADMIN_API_TOKEN: NonEmptyString,
IO_FUNCTIONS_ADMIN_BASE_URL: NonEmptyString,

MESSAGE_CONTAINER_NAME: NonEmptyString,
OPT_OUT_EMAIL_SWITCH_DATE: DateFromTimestamp,

QueueStorageConnection: NonEmptyString,

SANDBOX_FISCAL_CODE: NonEmptyString,
SUBSCRIPTIONS_FEED_TABLE: NonEmptyString,

WEBHOOK_CHANNEL_URL: NonEmptyString,

Expand All @@ -65,6 +74,8 @@ export const IConfig = t.intersection([

isProduction: t.boolean
}),
MessageContentStorageAccount,
SubscriptionFeedStorageAccount,
InternalStorageAccount,
MailerConfig
]);
Expand Down