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 committed Oct 30, 2023
1 parent a669cb3 commit 4f2ddae
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 4f2ddae

Please sign in to comment.