From 64af8b45cd847f4eb2218e23d9469ac894f9af00 Mon Sep 17 00:00:00 2001 From: flyingImer Date: Wed, 2 Mar 2022 01:50:08 +0000 Subject: [PATCH] chore: cleanup --- src/index.ts | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/index.ts b/src/index.ts index 72ff78e8..8ac6b9fc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -146,17 +146,22 @@ export class DistributedSemaphore extends Construct { updateExpression: 'SET #currentlockcount = #currentlockcount - :decrease REMOVE #lockownerid', conditionExpression: 'attribute_exists(#lockownerid)', returnValues: DynamoReturnValues.UPDATED_NEW, - }).addRetry({ - errors: ['DynamoDB.ConditionalCheckFailedException'], - maxAttempts: 0, - }).addRetry({ - errors: [Errors.ALL], - maxAttempts: 5, - backoffRate: 1.5, - }).addCatch( - successState, { - errors: ['DynamoDB.ConditionalCheckFailedException'], - }); - return getLock.next(doWork).next(releaseLock).next(successState); + }); + + return getLock + .next(doWork) + .next( + releaseLock.addRetry({ + errors: ['DynamoDB.ConditionalCheckFailedException'], + maxAttempts: 0, + }).addRetry({ + errors: [Errors.ALL], + maxAttempts: 5, + backoffRate: 1.5, + }).addCatch( + successState, { + errors: ['DynamoDB.ConditionalCheckFailedException'], + })) + .next(successState); } } \ No newline at end of file