Skip to content

chore(spanner): updated the sample to be same as other lang #5325

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

Conversation

surbhigarg92
Copy link
Contributor

No description provided.

@surbhigarg92 surbhigarg92 requested review from a team as code owners May 21, 2025 13:00
@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 May 21, 2025
Copy link

@gemini-code-assist gemini-code-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.

Hello @surbhigarg92, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

Hello! Gemini here, providing a summary of this pull request. Based on the title, the primary goal of this PR is a chore to update the Spanner Go sample code for setting the maximum commit delay (maxCommitDelay) to align it with the naming conventions used in samples for other languages. This involves renaming the function and updating its usage in the integration tests.

Highlights

  • Sample Code Alignment: The main purpose is to make the Go Spanner sample for setting the maximum commit delay consistent with samples provided in other programming languages.
  • Function Rename: The function maxCommitDelay in the spanner_max_commit_delay.go sample file has been renamed to setMaxCommitDelay.
  • Integration Test Update: The call to the renamed function in the integration_test.go file has been updated to reflect the new name, setMaxCommitDelay.
  • Comment Refinement: Comments within the spanner_max_commit_delay.go file have been updated or removed for clarity and consistency.

Changelog

  • spanner/spanner_snippets/spanner/integration_test.go
    • Updated the call to the sample function from maxCommitDelay to setMaxCommitDelay (line 335).
  • spanner/spanner_snippets/spanner/spanner_max_commit_delay.go
    • Renamed the function maxCommitDelay to setMaxCommitDelay (line 29).
    • Updated the comment describing the db parameter (line 29).
    • Removed detailed comments explaining the MaxCommitDelay and ReturnCommitStats options (lines 38-43).
    • Updated error message strings to use the new function name setMaxCommitDelay (lines 34, 51).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A function renamed,
Aligning samples with care,
Tests now pass cleanly.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-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.

Code Review

This pull request updates a Spanner Go sample, primarily by renaming the maxCommitDelay function to setMaxCommitDelay for consistency with samples in other languages, and adjusting associated comments and error messages. The changes are generally clear and align with the stated goal.

Summary of Findings

  • Removal of Explanatory Comment: A detailed comment explaining the purpose, default behavior, and valid range of MaxCommitDelay was removed from spanner_max_commit_delay.go. While this aligns with the goal of consistency across language samples, it might reduce the sample's clarity for users learning about this feature. A suggestion was made to consider re-adding a concise version or ensuring the information is easily accessible elsewhere.

Merge Readiness

The pull request is largely in good shape and achieves its goal of consistency. One point regarding a removed explanatory comment has been raised for consideration, which might impact the clarity of the sample for new users. This is a medium severity suggestion and can be discussed. As an AI, I am not authorized to approve pull requests; please ensure this change is reviewed and approved by a human maintainer before merging.

func maxCommitDelay(w io.Writer, db string) error {
// db = `projects/<project>/instances/<instance-id>/database/<database-id>`
func setMaxCommitDelay(w io.Writer, db string) error {
// db is the fully-qualified database name of the form `projects/<project>/instances/<instance-id>/database/<database-id>`
Copy link
Contributor

Choose a reason for hiding this comment

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

add example value to be consistent with other samples
// db := "projects/my-project/instances/my-instance/databases/my-database"

https://github.com/GoogleCloudPlatform/golang-samples/blob/main/CONTRIBUTING.md#function-arguments-for-snippets

@telpirion telpirion self-assigned this May 29, 2025
@rahul2393 rahul2393 merged commit b9a0945 into GoogleCloudPlatform:main May 30, 2025
9 checks passed
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.

4 participants