From c8ecfe1e2c2e703a78550f81b25b86a8f6507a78 Mon Sep 17 00:00:00 2001 From: caseybrookes Date: Fri, 15 Mar 2024 10:58:09 -0400 Subject: [PATCH] fix(queue): allow queue url defined via async fn --- .depcheckrc.yml | 1 + src/logic/withAsyncTaskExecutionLifecycleQueue.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.depcheckrc.yml b/.depcheckrc.yml index 1896496..5c78306 100644 --- a/.depcheckrc.yml +++ b/.depcheckrc.yml @@ -11,3 +11,4 @@ ignores: - date-fns - husky - if-env + - aws-lambda diff --git a/src/logic/withAsyncTaskExecutionLifecycleQueue.ts b/src/logic/withAsyncTaskExecutionLifecycleQueue.ts index 19193b6..c34b277 100644 --- a/src/logic/withAsyncTaskExecutionLifecycleQueue.ts +++ b/src/logic/withAsyncTaskExecutionLifecycleQueue.ts @@ -1,5 +1,5 @@ import type { LogMethods } from 'simple-leveled-log-methods'; -import { HasMetadata } from 'type-fns'; +import { HasMetadata, isAFunction } from 'type-fns'; import { AsyncTaskDao, @@ -49,7 +49,7 @@ export const withAsyncTaskExecutionLifecycleQueue = < messageBody: string; }) => Promise; }; - queue: { url: string }; + queue: { url: string | (() => Promise) }; }) => { return async (args: P): Promise> => { // try to find the task by unique @@ -104,8 +104,11 @@ export const withAsyncTaskExecutionLifecycleQueue = < ...taskReadyToQueue, status: AsyncTaskStatus.QUEUED, }; + log.debug('adding task to queue', { + task: taskToQueue, + }); await sqs.sendMessage({ - queueUrl: queue.url, + queueUrl: isAFunction(queue.url) ? await queue.url() : queue.url, messageBody: JSON.stringify({ task: taskToQueue }), });