Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

feat!: Replace RunTransaction() with Client::Commit(functor) #975

Merged
merged 3 commits into from
Oct 24, 2019

Conversation

devbww
Copy link
Contributor

@devbww devbww commented Oct 23, 2019

Replace g:c:s:RunTransaction() with a new g:c:s:Client::Commit()
overload. This is similar to the existing Commit(), but you
specify how to create the mutations, instead of passing them
directly, which is what is needed to create the rerun loop.

The "mutator" callback no longer receives the target Client as
an argument because many mutators don't need it. If you want
a client in your callback, you will need to bind it yourself.

The Transaction::ReadWriteOptions have been removed as there
are no options, and being able to preallocate RW transactions
pretty much requires that remains the case.

Session affinity over reruns is still to be addressed.

BREAKING CHANGE

Fixes #557.


This change is Reviewable

Replace g:c:s:RunTransaction() with a new g:c:s:Client::Commit()
overload.  This is similar to the existing Commit(), but you
specify how to create the mutations, instead of passing them
directly, which is what is needed to create the rerun loop.

The "mutator" callback no longer receives the target Client as
an argument because many mutators don't need it.  If you want
a client in your callback, you will need to bind it yourself.

The Transaction::ReadWriteOptions have been removed as there
are no options, and being able to preallocate RW transactions
pretty much requires that remains the case.

Session affinity over reruns is still to be addressed.

BREAKING CHANGE

Fixes googleapis#557.
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 23, 2019
@codecov
Copy link

codecov bot commented Oct 23, 2019

Codecov Report

Merging #975 into master will decrease coverage by 0.16%.
The diff coverage is 91.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #975      +/-   ##
==========================================
- Coverage   94.12%   93.96%   -0.17%     
==========================================
  Files          96       96              
  Lines        4068     4058      -10     
==========================================
- Hits         3829     3813      -16     
- Misses        239      245       +6
Impacted Files Coverage Δ
google/cloud/spanner/mutations.h 98.07% <ø> (ø) ⬆️
google/cloud/spanner/client.h 100% <ø> (ø) ⬆️
google/cloud/spanner/samples/samples.cc 89.35% <100%> (-0.06%) ⬇️
google/cloud/spanner/client.cc 81.81% <88.88%> (-0.19%) ⬇️
...loud/spanner/internal/partial_result_set_resume.cc 90.9% <0%> (-4.55%) ⬇️
google/cloud/spanner/internal/retry_loop.h 95.45% <0%> (-4.55%) ⬇️
google/cloud/spanner/internal/polling_loop.h 91.89% <0%> (-2.71%) ⬇️
google/cloud/spanner/internal/spanner_stub.cc 66.66% <0%> (-2.23%) ⬇️
google/cloud/spanner/value.cc 97.04% <0%> (-0.58%) ⬇️
google/cloud/spanner/value.h 93.51% <0%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 05ebaec...06ae7ca. Read the comment docs.

@devbww devbww marked this pull request as ready for review October 23, 2019 21:18
Copy link
Contributor

@coryan coryan left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 9 of 9 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @devbww, @devjgm, @mr-salty, and @scotthart)


google/cloud/spanner/client.h, line 416 at r1 (raw file):

   * Commits a read-write transaction.
   *
   * Calls the `mutator` in the context of a new read-write transaction.  The

nit: Doxygen understand @p mutator as a reference to the parameter called mutator and it formats and links correctly.


google/cloud/spanner/client.h, line 448 at r1 (raw file):

   */
  StatusOr<CommitResult> Commit(
      std::function<StatusOr<Mutations>(Transaction)> const& mutator);

FYI: I think it would be nice if this used some defaults set in the constructor or something, but this PR is better than what we have today, so LGTM.

@devbww
Copy link
Contributor Author

devbww commented Oct 24, 2019

nit: Doxygen understand @p mutator as a reference to the parameter called mutator and it formats and links correctly.

Done (et seq).

@devbww
Copy link
Contributor Author

devbww commented Oct 24, 2019

FYI: I think it would be nice if this used some defaults set in the constructor or something, but this PR is better than what we have today

Yes, agreed.

Copy link
Contributor

@coryan coryan left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @devjgm, @mr-salty, and @scotthart)

Copy link
Contributor

@devjgm devjgm left a comment

Choose a reason for hiding this comment

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

Thanks, Brad!

@devbww devbww merged commit 89c3d66 into googleapis:master Oct 24, 2019
@devbww devbww deleted the commit branch October 24, 2019 16:37
devjgm pushed a commit to devjgm/google-cloud-cpp that referenced this pull request May 7, 2020
…pis/google-cloud-cpp-spanner#975)

Replace g:c:s:RunTransaction() with a new g:c:s:Client::Commit()
overload.  This is similar to the existing Commit(), but you
specify how to create the mutations, instead of passing them
directly, which is what is needed to create the rerun loop.

The "mutator" callback no longer receives the target Client as
an argument because many mutators don't need it.  If you want
a client in your callback, you will need to bind it yourself.

The Transaction::ReadWriteOptions have been removed as there
are no options, and being able to preallocate RW transactions
pretty much requires that remains the case.

Session affinity over reruns is still to be addressed.

BREAKING CHANGE

Fixes googleapis/google-cloud-cpp-spanner#557.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace RunTransaction() with Client::Commit(functor)
4 participants