Skip to content

Conversation

@ShuranZhang
Copy link
Contributor

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
@snippet-bot
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

@ghost ghost 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

@ghost ghost 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
@telpirion telpirion enabled auto-merge (squash) January 21, 2025 19:24
auto-merge was automatically disabled January 21, 2025 23:54

Head branch was pushed to by a user without write access

@ShuranZhang ShuranZhang force-pushed the change-streams-txn-exclusion branch from 7e7a139 to 071aef7 Compare January 21, 2025 23:54
@rahul2393 rahul2393 enabled auto-merge (squash) January 22, 2025 04:00
@rahul2393 rahul2393 merged commit 3a81f8e into GoogleCloudPlatform:main Jan 23, 2025
9 checks passed
@ShuranZhang ShuranZhang deleted the change-streams-txn-exclusion branch January 24, 2025 19:14
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.

3 participants