-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cached S3, dynamo and SQS clients
- Loading branch information
Alan Shaw
committed
Sep 24, 2024
1 parent
661d1fd
commit 3a3290b
Showing
2 changed files
with
21 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
import { SQSClient } from '@aws-sdk/client-sqs' | ||
|
||
/** @type {Record<string, import('@aws-sdk/client-sqs').SQSClient>} */ | ||
const sqsClients = {} | ||
|
||
/** | ||
* @param {import('./types.js').QueueConnect | SQSClient} target | ||
*/ | ||
export function connectQueue (target) { | ||
if (target instanceof SQSClient) { | ||
return target | ||
} | ||
return new SQSClient(target) | ||
if (!sqsClients[target.region]) { | ||
sqsClients[target.region] = new SQSClient(target) | ||
} | ||
return sqsClients[target.region] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters