Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

samples: add samples for tagging feature - #1478

Closed
mayurkale22 wants to merge 2 commits into
googleapis:mainfrom
mayurkale22:tag_samples
Closed

samples: add samples for tagging feature#1478
mayurkale22 wants to merge 2 commits into
googleapis:mainfrom
mayurkale22:tag_samples

Conversation

@mayurkale22

@mayurkale22 mayurkale22 commented Sep 30, 2021

Copy link
Copy Markdown
Contributor

Supersedes #1042

Adds a sample for assigning and querying tags.

Follow-up to #576

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> ☕️

@mayurkale22
mayurkale22 requested a review from a team September 30, 2021 17:50
@snippet-bot

snippet-bot Bot commented Sep 30, 2021

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 2 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label Bot added the api: spanner Issues related to the googleapis/java-spanner API. label Sep 30, 2021
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Sep 30, 2021
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Sep 30, 2021
@mayurkale22
mayurkale22 requested a review from larkee September 30, 2021 18:09
databaseClient
.readWriteTransaction(Options.tag("app=concert,env=dev"))
.run(
new TransactionCallable<Void>() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: could you use Java 8 lambda notation instead of an anonymous class?

.run(transaction -> {
  ...
})

// Execute query multiple times to give a better chance of being part of the TopN tables.
for (int i = 0; i < 50; i++) {
final String out = runSample(() -> TransactionWithTagSample.setRequestTag(client));
assertThat(out).contains("1 1 title 1");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How long does this take to run? Could we break as soon as we reach a condition?

if (queryStatsFound) {
break;
}
Thread.sleep(5000);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we reduce the sleep time here?

@larkee larkee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The set_transaction_tag sample is based on an outdated version of the spec. Please update it to match the current spec.

@thiagotnunes

Copy link
Copy Markdown
Contributor

Closing in favour of #1496

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: spanner Issues related to the googleapis/java-spanner API. cla: yes This human has signed the Contributor License Agreement. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants