Skip to content

Commit

Permalink
fix(queue): allow queue url defined via async fn
Browse files Browse the repository at this point in the history
  • Loading branch information
caseybrookes committed Mar 15, 2024
1 parent d907ef4 commit c8ecfe1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ ignores:
- date-fns
- husky
- if-env
- aws-lambda
9 changes: 6 additions & 3 deletions src/logic/withAsyncTaskExecutionLifecycleQueue.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -49,7 +49,7 @@ export const withAsyncTaskExecutionLifecycleQueue = <
messageBody: string;
}) => Promise<void>;
};
queue: { url: string };
queue: { url: string | (() => Promise<string>) };
}) => {
return async (args: P): Promise<HasMetadata<T>> => {
// try to find the task by unique
Expand Down Expand Up @@ -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 }),
});

Expand Down

0 comments on commit c8ecfe1

Please sign in to comment.