From a19ec8efea5cb41abaa1427fe9c736f87b3cb3a8 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Mon, 29 Aug 2022 13:20:39 +0800 Subject: [PATCH] Hardcode queue name --- packages/api/src/util.ts | 13 +++++++++---- packages/api/src/utils/createTask.ts | 9 ++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/api/src/util.ts b/packages/api/src/util.ts index 53d2daa83..0ca9ad8b8 100755 --- a/packages/api/src/util.ts +++ b/packages/api/src/util.ts @@ -65,8 +65,6 @@ interface BackendEnv { reminderTaskHanderUrl: string integrationTaskHandlerUrl: string textToSpeechTaskHandlerUrl: string - textToSpeechName: string - textToSpeechLocation: string } fileUpload: { gcsUploadBucket: string @@ -96,6 +94,9 @@ interface BackendEnv { speechKey: string speechRegion: string } + gcp: { + location: string + } } /*** @@ -150,6 +151,7 @@ const nullableEnvVars = [ 'TEXT_TO_SPEECH_TASK_HANDLER_URL', 'AZURE_SPEECH_KEY', 'AZURE_SPEECH_REGION', + 'GCP_LOCATION', ] // Allow some vars to be null/empty /* If not in GAE and Prod/QA/Demo env (f.e. on localhost/dev env), allow following env vars to be null */ @@ -235,8 +237,6 @@ export function getEnv(): BackendEnv { reminderTaskHanderUrl: parse('REMINDER_TASK_HANDLER_URL'), integrationTaskHandlerUrl: parse('INTEGRATION_TASK_HANDLER_URL'), textToSpeechTaskHandlerUrl: parse('TEXT_TO_SPEECH_TASK_HANDLER_URL'), - textToSpeechName: parse('TEXT_TO_SPEECH_QUEUE_NAME'), - textToSpeechLocation: parse('TEXT_TO_SPEECH_QUEUE_LOCATION'), } const imageProxy = { url: parse('IMAGE_PROXY_URL'), @@ -277,6 +277,10 @@ export function getEnv(): BackendEnv { speechRegion: parse('AZURE_SPEECH_REGION'), } + const gcp = { + location: parse('GCP_LOCATION'), + } + return { pg, client, @@ -296,6 +300,7 @@ export function getEnv(): BackendEnv { sendgrid, readwise, azure, + gcp, } } diff --git a/packages/api/src/utils/createTask.ts b/packages/api/src/utils/createTask.ts index 962b796ee..c8102fa02 100644 --- a/packages/api/src/utils/createTask.ts +++ b/packages/api/src/utils/createTask.ts @@ -207,13 +207,15 @@ export const deleteTask = async ( * @param userId - Id of the user authorized * @param saveRequestId - Id of the article_saving_request table record * @param priority - Priority of the task + * @param queue - Queue name * @returns Name of the task created */ export const enqueueParseRequest = async ( url: string, userId: string, saveRequestId: string, - priority: 'low' | 'high' = 'high' + priority: 'low' | 'high' = 'high', + queue = env.queue.name ): Promise => { const { GOOGLE_CLOUD_PROJECT } = process.env const payload = { @@ -247,6 +249,7 @@ export const enqueueParseRequest = async ( payload, priority, taskHandlerUrl, + queue, }) if (!createdTasks || !createdTasks[0].name) { logger.error(`Unable to get the name of the task`, { @@ -339,8 +342,8 @@ export const enqueueTextToSpeech = async ({ priority, textType = 'ssml', bucket = env.fileUpload.gcsUploadBucket, - queue = env.queue.textToSpeechName, - location = env.queue.textToSpeechLocation, + queue = 'omnivore-demo-text-to-speech-queue', + location = env.gcp.location, }: { userId: string speechId: string