Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

feat: support update as create in bundle service #80

Merged
merged 6 commits into from
Jun 1, 2021

Conversation

justinusmenzel
Copy link
Contributor

Description of changes:
In order to lock resources for operations other than 'create' the latest version ID needs to be looked up first.
If the resource isn't found a ResourceNotFoundError is thrown.
With this change only ResourceNotFoundErrors for operations other than 'update' are being counted and result in a failed transaction.
By allowing 'update' operation for resources that don't exist in dynamo yet using update as create is possible.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Comment on lines 193 to 194
// allow for update as create scenario
if (itemResponse instanceof ResourceNotFoundError && itemsToLock[i].operation !== 'update') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this works, but it will inadvertently enable update as crate for all customers using bundles/transactions.

DynamoDbDataService has a parameter supportUpdateCreate that enables update as create for the regular update operation but doesn't address bundles/transactions. I think that we can pass down that same parameter to DynamoDbBundleService and use it to conditionally apply your changes.

constructor(dynamoDb: DynamoDB, supportUpdateCreate: boolean = false) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added the supportUpdateCreate flag to dynamoDbBundleService.ts. Creating a test seems not so trivial. I'll give it a shot.

Justinus Menzel added 2 commits May 26, 2021 12:26
@rsmayda rsmayda requested a review from carvantes May 31, 2021 23:41
Copy link
Contributor

@rsmayda rsmayda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! @carvantes for final review and merge

@carvantes carvantes changed the title Support update as create feat: support update as create in bundle service Jun 1, 2021
@rsmayda rsmayda merged commit bf1366d into awslabs:mainline Jun 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants