-
Notifications
You must be signed in to change notification settings - Fork 14
feat!: Replace RunTransaction() with Client::Commit(functor) #975
Conversation
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.
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Done (et seq). |
Yes, agreed. |
There was a problem hiding this 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:complete! all files reviewed, all discussions resolved (waiting on @devjgm, @mr-salty, and @scotthart)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Brad!
…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.
Replace
g:c:s:RunTransaction()
with a newg:c:s:Client::Commit()
overload. This is similar to the existing
Commit()
, but youspecify 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
asan 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 thereare 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](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)