+
Skip to content

feat(pubsub/v2): add new v2 samples #5344

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

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

Conversation

hongalex
Copy link
Contributor

@hongalex hongalex commented Jul 1, 2025

All code has been pre-approved in the individual PRs that made up this trunk branch:

Topics: #5336
Subscriptions: #5339
Schemas: #5340
Misc comments: #5343

hongalex and others added 4 commits June 24, 2025 15:38
* feat(pubsub): add v2 topic and publishing samples

* address code review comments
* feat(pubsub): add v2 subscription samples

* fix issue with line length

* update quickstart

* address gemini code review comments

* Add doc comments to client.Subscriber calls

Clarify that client.Subscriber accepts either a resource ID or a fully qualified name for the subscription. If a resource ID is used, the project ID from the client is assumed.

* fix region tag issue

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
* feat(pubsub): add v2 rewritten schema samples

* resolve gemini review comments
* docs(pubsub): add comments for publisher instantiation

* update comments and var names

* change more variable naming
@hongalex hongalex requested review from a team as code owners July 1, 2025 22:09
@product-auto-label product-auto-label bot added api: pubsub Issues related to the Pub/Sub API. samples Issues that are directly related to samples. labels Jul 1, 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.

Summary of Changes

Hello @hongalex, 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!

This pull request introduces a comprehensive update to the Google Cloud Pub/Sub Go samples, transitioning them to utilize the new v2 client library. The changes refactor the sample code to integrate with the updated API design, providing current and idiomatic examples for Pub/Sub operations.

Highlights

  • Client Library Upgrade: All Google Cloud Pub/Sub Go samples have been migrated from the v1 to the v2 client library (cloud.google.com/go/pubsub/v2), ensuring they demonstrate the latest client features and API patterns.
  • API Surface Alignment: The sample code has been updated to align with the v2 client's API surface, which includes using dedicated admin clients (e.g., TopicAdminClient, SubscriptionAdminClient, SchemaClient) for management operations and Publisher/Subscriber for data plane interactions. This also involves adopting protobuf-based request and response types (pubsubpb).
  • Dependency Management: The go.mod and go.sum files have been updated to reflect the new v2 Pub/Sub client dependency and other related Go module version bumps.
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.

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 migrates the Pub/Sub samples from the v1 Go client to the v2 client. The changes are extensive and touch almost all sample files for topics, subscriptions, and schemas. The migration correctly adopts new v2 API patterns, such as using separate admin clients for resource management and Publisher/Subscriber for data plane operations. I've identified a critical issue in pubsub/topics/publish_retry.go where an incorrect type is used, which will cause a compilation failure. I also found several high-severity issues related to behavioral changes (missing AckDeadline in subscription creation) and incomplete test cleanup logic that could lead to resource leaks. Additionally, there are several medium-severity issues regarding reduced test coverage and minor inconsistencies in the samples. Overall, the migration is on the right track, but these issues should be addressed to ensure the correctness and quality of the new v2 samples.

Comment on lines +37 to 38
PublisherCallOptions: &vkit.TopicAdminCallOptions{
Publish: []gax.CallOption{

Choose a reason for hiding this comment

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

critical

The PublisherCallOptions field in pubsub.ClientConfig is being set with vkit.TopicAdminCallOptions. This is incorrect and will cause a compilation error as the field expects a *vkit.PublisherCallOptions.

Suggested change
PublisherCallOptions: &vkit.TopicAdminCallOptions{
Publish: []gax.CallOption{
PublisherCallOptions: &vkit.PublisherCallOptions{
Publish: []gax.CallOption{

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载