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: add support for tagging to Connection API #623
Conversation
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.
Some suggestions could not be made:
- google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/Connection.java
- lines 38-38
@@ -959,6 +1034,7 @@ private UnitOfWork createNewUnitOfWork() { | |||
.setReadOnlyStaleness(readOnlyStaleness) | |||
.setStatementTimeout(statementTimeout) | |||
.withStatementExecutor(statementExecutor) | |||
.setTransactionTag(transactionTag) |
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.
How will this behave if the user never set a transaction tag?
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.
It is nullable, so that is not a problem. It is verified by this test case.
} | ||
|
||
@Override | ||
public void setStatementTag(String tag) { |
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.
Out of curiosity, could we prevent the calling of this for a COMMIT
? The user should not be able to do a statement tag in that case.
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.
Good question. We can't prevent it before the COMMIT
, but we can throw an exception if COMMIT
is called after a statement tag has been set, and I think that makes sense as we are quite strict in checking the order of other statements (e.g. you are only allowed to get a commit timestamp if you actually committed etc.).
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.
I've changed the implementation to check for this, and to throw an error if the application tries to set a statement tag for a COMMIT
or ROLLBACK
statement. This change also adds a change relating to DML batches: DML batches can only include one statement tag, as the statements are sent as one ExecuteBatchDmlRequest
, which only allows one statement tag. This statement tag must be set before calling START BATCH DML
, e.g.
SET STATEMENT_TAG = 'tag-1';
START BATCH DML;
INSERT INTO Singers (SingerId, Name) VALUES (1, 'Morrison');
INSERT INTO Singers (SingerId, Name) VALUES (2, 'Pieterson');
RUN BATCH;
3ab89ea
to
510fdb3
Compare
Codecov Report
@@ Coverage Diff @@
## master #623 +/- ##
============================================
+ Coverage 85.06% 85.23% +0.17%
- Complexity 2585 2687 +102
============================================
Files 143 155 +12
Lines 14130 14531 +401
Branches 1368 1376 +8
============================================
+ Hits 12019 12386 +367
- Misses 1540 1570 +30
- Partials 571 575 +4
Continue to review full report at Codecov.
|
@thiagotnunes Would you mind taking a final look before I merge? I've rebased on master and realigned with the last choice that were made for tagging in the client library. Also: This is a binary breaking change as it adds methods to the |
🤖 I have created a release \*beep\* \*boop\* --- ## [6.9.0](https://www.github.com/googleapis/java-spanner/compare/v6.8.0...v6.9.0) (2021-07-05) ### Features * add support for tagging to Connection API ([#623](https://www.github.com/googleapis/java-spanner/issues/623)) ([5722372](https://www.github.com/googleapis/java-spanner/commit/5722372b7869828e372dec06e80e5b0e7280af61)) * **spanner:** add leader_options to InstanceConfig and default_leader to Database ([#1271](https://www.github.com/googleapis/java-spanner/issues/1271)) ([f257671](https://www.github.com/googleapis/java-spanner/commit/f25767144344f0df67662f1b3ef662902384599a)) * support setting an async executor provider ([#1263](https://www.github.com/googleapis/java-spanner/issues/1263)) ([369c8a7](https://www.github.com/googleapis/java-spanner/commit/369c8a771ec48fa1476236f800b0e8eb5982a33c)) ### Dependencies * update dependency com.google.cloud:google-cloud-shared-dependencies to v1.4.0 ([#1269](https://www.github.com/googleapis/java-spanner/issues/1269)) ([025e162](https://www.github.com/googleapis/java-spanner/commit/025e162813d6321dabe49e32f00934f9ae334e24)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This is an auto-generated regeneration of the .pb.go files by cloud.google.com/go/internal/gapicgen. Once this PR is submitted, genbot will update the corresponding PR to depend on the newer version of go-genproto, and assign reviewers. Whilst this or any regen PR is open in go-genproto, genbot will not create any more regeneration PRs. If all regen PRs are closed, gapicgen will create a new set of regeneration PRs once per night. If you have been assigned to review this PR, please: - Ensure that CI is passing. If it's failing, it requires your manual attention. - Approve and submit this PR if you believe it's ready to ship. That will prompt genbot to assign reviewers to the google-cloud-go PR. Corresponding google-cloud-go PR: googleapis/google-cloud-go#4311 Changes: chore: Update networksecurity v1beta1 BUILD.bazel for python PiperOrigin-RevId: 381257429 Source-Link: googleapis/googleapis@f5b06c2 chore: regenerate API index Source-Link: googleapis/googleapis@8cd4d12 feat(servicedirectory): Update Service Directory v1beta1 protos to include VPC Network field, and create/modify timestamp fields. PiperOrigin-RevId: 381234166 Source-Link: googleapis/googleapis@d69baf2 fix(servicecontrol): add dependency log_severity.proto Committer: @summerji PiperOrigin-RevId: 381179420 Source-Link: googleapis/googleapis@8b976f7 feat(spanner): add JSON type PiperOrigin-RevId: 381156241 Source-Link: googleapis/googleapis@fb5c4fb chore: regenerate API index Source-Link: googleapis/googleapis@c4d3151 feat: filestore public protos Committer: @vchudnov-g PiperOrigin-RevId: 381148500 Source-Link: googleapis/googleapis@4c8d14a feat(asset): add new searchable fields (memberTypes, roles, project, folders and organization), new request fields (assetTypes and orderBy) and new response fields (assetType, folders and organization) in SearchAllIamPolicies PiperOrigin-RevId: 381145907 Source-Link: googleapis/googleapis@5d301f9 chore: regenerate API index Source-Link: googleapis/googleapis@aeb62a6 feat: dataflow public protos Committer: @alexander-fenster PiperOrigin-RevId: 380930750 Source-Link: googleapis/googleapis@3dc9b8e chore: regenerate API index Source-Link: googleapis/googleapis@02f6236 feat: networksecurity public protos Committer: @alexander-fenster PiperOrigin-RevId: 380923948 Source-Link: googleapis/googleapis@370df45 chore: release gapic-generator-java v1.0.15 Committer: @miraleung PiperOrigin-RevId: 380916790 Source-Link: googleapis/googleapis@7c7d22f chore: remove legacy, unused YAML from gapic directory PiperOrigin-RevId: 380835888 Source-Link: googleapis/googleapis@dba65e3 chore(resourcesettings): update resourcesettings build rules Committer: @neenushaji PiperOrigin-RevId: 380831596 Source-Link: googleapis/googleapis@2c1d1b2 build(clouddms): fix package name hint PiperOrigin-RevId: 380817131 Source-Link: googleapis/googleapis@284d1dd feat(documentai): update ReviewDocumentRequest to allow set priority and enable validation. PiperOrigin-RevId: 380732771 Source-Link: googleapis/googleapis@87fc4d4 feat!(dialogflow/cx): mark agent.default_language_code as required feat: add return_partial response to Fulfillment docs: add notes to train agent before sending queries PiperOrigin-RevId: 380726996 Source-Link: googleapis/googleapis@a5cec0a chore: Update source_v1 BUILD.bazel for python PiperOrigin-RevId: 380710437 Source-Link: googleapis/googleapis@0e48ca4 chore: regenerate API index Source-Link: googleapis/googleapis@89b01d8 feat(pubsublite): Add SeekSubscription and Operations to API PiperOrigin-RevId: 380660182 Source-Link: googleapis/googleapis@b601f02 chore(gkeconnect/gateway): fix multi-version package names in grpc_service_config for gkeconnect Committer: @miraleung PiperOrigin-RevId: 380655273 Source-Link: googleapis/googleapis@9250dff chore: remove all monolith Bazel deps chore: release gapic-generator-csharp v1.3.7 chore: release gapic-generator-go 0.20.5 chore: release gapic-generator-java 1.0.14 chore: release gapic-generator-php 1.0.1 chore: release gapic-generator-python 0.50.0 chore: update gapic-generator-ruby to the latest commit chore: release gapic-generator-typescript 1.5.0 Committer: @miraleung PiperOrigin-RevId: 380641501 Source-Link: googleapis/googleapis@076f7e9 docs(dialogflow): added notes to train agent prior to sending queries fix: added resource reference to agent_version PiperOrigin-RevId: 380595849 Source-Link: googleapis/googleapis@5fe3c63 docs(dialogflow/cx): added notes to train agent before sending queries PiperOrigin-RevId: 380267079 Source-Link: googleapis/googleapis@01bad53 chore(gkeconnect/gateway): Update gkeconnect/gateway v1beta1 BUILD.bazel for python PiperOrigin-RevId: 380077711 Source-Link: googleapis/googleapis@9d8dbc0 chore: regenerate API index Source-Link: googleapis/googleapis@052eb55 chore(resourcemanager): remove protoc-gen-docs_plugin from WORKSPACE PiperOrigin-RevId: 380020641 Source-Link: googleapis/googleapis@cb44b17
Adds support for tagging in the Connection API. This is needed to support tagging in the JDBC driver.
This is a binary breaking change, as it adds 4 methods to the
Connection
interface. That interface is marked as@InternalApi
and warns that it may make breaking changes without prior notice.