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

samples: add samples for tagging feature #1478

Closed
wants to merge 2 commits into from
Closed

samples: add samples for tagging feature #1478

wants to merge 2 commits into from

Conversation

mayurkale22
Copy link
Member

@mayurkale22 mayurkale22 commented Sep 30, 2021

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 as a code owner September 30, 2021 17:50
@snippet-bot
Copy link

snippet-bot bot commented Sep 30, 2021

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
databaseClient
.readWriteTransaction(Options.tag("app=concert,env=dev"))
.run(
new TransactionCallable<Void>() {
Copy link
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
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
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?

Copy link

@larkee larkee left a comment

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
Contributor

Closing in favour of #1496

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

None yet

4 participants