Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Begin transactions before each transaction read/write merge onto main #1234

Conversation

danieljbruce
Copy link
Contributor

@danieljbruce danieljbruce commented Feb 23, 2024

Summary

This PR contains all the work necessary to ensure that transactions are always started before the first transaction read/write call. It also solves various concurrency problems with transactions like ensuring that two transactions are never started at the same time.

Several PRs have been merged onto this feature branch so this PR contains all the work across these PRs and finally merges it into main. The other PRs have already been reviewed so this PR is one last review before the changes go fully into production.

PRs that make up this feature branch

  1. refactor: Break transaction.run into smaller pieces for use with async functions and other read/write calls #1196
  2. refactor: Move commit logic and add tests that prepare for transaction function changes #1202
  3. feat: Begin transactions before each transaction read/write #1205

danieljbruce and others added 2 commits November 17, 2023 11:30
…c functions and other read/write calls (googleapis#1196)

* Add a unit test for commit as a non-tx

The fact that using a transaction object to do a commit results in a non-transaction should be documented so that if we decide to introduce a change later where this behaves differently then it is well documented.

# Conflicts:
#	test/transaction.ts

* use linter

* Write tests to capture current behavior of error

When begin transaction sends back an error, we want some tests to capture what the behavior is so that when we make changes to the run function then behavior is preserved.

* Add tests for passing a response

A response should reach the user the right way. Add tests to make sure behavior is preserved.

* run async close to working

In the run function delegate calls to runAsync and use run async to make promise calls

* Add runAsync to promise excludes

This allows this function to return a promise instead of a promise wrapped in a promise. This makes the tests pass and behave the way they should.

* Remove space

* Change to use this instead of self

Do not call request from self

* Eliminate unused comments

* Add two comments

Comments should actually explain what is being done

* Remove the commit test for this PR

The commit test for this PR should be removed because it is not really relevant for the async run functionality.

* Clarify types throughout the function

The types used should be very specific so that reading the code isn’t confusing.

* Add a bit more typing for clarity

Add a type to the resolve function just to introduce more clarity

* Change types used in the data client callback

Make the types more specific in the data client callback so that it is easier to track down the signature and match against the begin transaction function.

* run the linter

* Add comments to clarify PR

* Refactor the parsing logic out of run

The parsing logic is going to be needed elsewhere so taking it apart now.

* Change interface of request promise callback

The interface name should be changed so that it matches what it is. It is the callback used to form a promise.

* Hide data completely

Change accessors to hide data completely instead of using the private modifier

* PR use if/else block

Eliminate the early return as suggested in the PR

* Add comments to document the new functions

The comments capture the parameters and return type.

* Update return type in docs

* Update the tests to include runAsync

runAsync should be in promisfy excludes

* refactor: Break transaction.run into smaller pieces for use with async functions and other read/write calls

* Rename a function to be more descriptive

Make sure it is explicit that we are parsing begin results.

* Modify comment

Modify comment so that it doesn’t reference the way the code was before.
…into nodejs-transaction-redesign-feature-branch
@danieljbruce danieljbruce requested review from a team as code owners February 23, 2024 15:42
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: datastore Issues related to the googleapis/nodejs-datastore API. labels Feb 23, 2024
@danieljbruce danieljbruce changed the title feat: Nodejs transaction redesign feature branch try again feat: Begin transactions before each transaction read/write merge onto main Feb 23, 2024
@danieljbruce danieljbruce added the owlbot:run Add this label to trigger the Owlbot post processor. label Feb 23, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Feb 23, 2024
@danieljbruce
Copy link
Contributor Author

This doesn't seem to have all the transaction work changes. I'll look into this further.

@danieljbruce
Copy link
Contributor Author

danieljbruce commented Feb 23, 2024

https://github.com/googleapis/nodejs-datastore/pull/1235/files was opened instead. It has the CLA override.

@daniel-sanche
Copy link

We missed out on merging PR #1234 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the googleapis/nodejs-datastore API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants