Skip to content

Commit

Permalink
chore(idempotency): refactor aws sdk init logic (#1768)
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamorosi authored Oct 30, 2023
1 parent 68fc758 commit 8b3bf04
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,17 @@ class DynamoDBPersistenceLayer extends BasePersistenceLayer {
this.staticPkValue =
config.staticPkValue ?? `idempotency#${this.idempotencyKeyPrefix}`;

this.client = new DynamoDBClient(config?.clientConfig ?? {});
if (config?.awsSdkV3Client) {
if (isSdkClient(config.awsSdkV3Client)) {
this.client = config.awsSdkV3Client;
} else {
if (config.awsSdkV3Client) {
if (!isSdkClient(config.awsSdkV3Client)) {
console.warn(
'awsSdkV3Client is not an AWS SDK v3 client, using default client'
);
this.client = new DynamoDBClient(config.clientConfig ?? {});
} else {
this.client = config.awsSdkV3Client;
}
} else {
this.client = new DynamoDBClient(config.clientConfig ?? {});
}
addUserAgentMiddleware(this.client, 'idempotency');
}
Expand Down

0 comments on commit 8b3bf04

Please sign in to comment.