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

feat(spanner): add change streams transaction exclusion sample #5071

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ShuranZhang
Copy link

Add sample for how to configure change streams transaction exclusion option for a read write transaction.

I don't have access to re-open #4108, this is basically a duplicate.

@ShuranZhang ShuranZhang requested review from a team as code owners January 13, 2025 21:32
Copy link

snippet-bot bot commented Jan 13, 2025

Here is the summary of changes.

You are about to add 1 region tag.

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

Copy link

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

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

Hi team,

I'm currently reviewing this pull request and will provide my feedback shortly. In the meantime, here's a summary for you and other reviewers to quickly get up to speed:

This pull request, authored by ShuranZhang, aims to add a sample demonstrating how to configure the transaction exclusion option for change streams in Spanner read-write transactions. Specifically, it adds a new sample that shows how to exclude a read-write transaction from being tracked by change streams.

Here's a breakdown of the changes:

  • New File: spanner/spanner_snippets/spanner/spanner_change_streams_txn_exclusion.go This file contains the new sample code that demonstrates how to exclude a read-write transaction from change streams using spanner.TransactionOptions{ExcludeTxnFromChangeStreams: true}. The code inserts and updates a row in the Singers table within a transaction, and then prints confirmation messages to the console.
  • Modified File: spanner/spanner_snippets/spanner/integration_test.go This file has been updated to include a test case for the new rwTxnExcludedFromChangeStreams function (lines 437-443). This test verifies that the transaction is correctly excluded from change streams by asserting that specific messages are present in the output.

The changes are well-structured and clearly demonstrate the intended functionality. The comments are helpful and the code is easy to follow.


And now, a little haiku to lighten the mood:

Streams flow, data bright,
Transactions, neatly kept,
Code review's delight.

Thanks,
Gemini

@product-auto-label product-auto-label bot added api: spanner Issues related to the Spanner API. samples Issues that are directly related to samples. labels Jan 13, 2025
Copy link

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

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

The sample demonstrates how to exclude read-write transactions from change streams. The code is well-structured and easy to understand. The PR description could be improved by adding a link to the documentation.

@telpirion telpirion self-assigned this Jan 14, 2025
@ShuranZhang ShuranZhang force-pushed the change-streams-txn-exclusion branch from 77c1062 to e08718d Compare January 16, 2025 22:22
@ShuranZhang ShuranZhang requested a review from telpirion January 17, 2025 01:17
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 Spanner API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants