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

docs(pubsub): add optimistic subscribe example #14272

Merged
merged 4 commits into from
May 23, 2024

Conversation

alevenberg
Copy link
Member

@alevenberg alevenberg commented May 22, 2024

This change is Reviewable

@product-auto-label product-auto-label bot added the api: pubsub Issues related to the Pub/Sub API. label May 22, 2024
@alevenberg alevenberg changed the title docs(pubsub): add optomistic subscribe example docs(pubsub): add optimistic subscribe example May 22, 2024
@alevenberg alevenberg marked this pull request as ready for review May 22, 2024 15:51
@alevenberg alevenberg requested a review from a team as a code owner May 22, 2024 15:51
Copy link

snippet-bot bot commented May 22, 2024

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

google/cloud/pubsub/samples/samples.cc Outdated Show resolved Hide resolved
google/cloud/pubsub/samples/samples.cc Outdated Show resolved Hide resolved
Copy link

codecov bot commented May 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.26%. Comparing base (365fea9) to head (f0f093b).
Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14272   +/-   ##
=======================================
  Coverage   93.26%   93.26%           
=======================================
  Files        2213     2213           
  Lines      193279   193325   +46     
=======================================
+ Hits       180266   180309   +43     
- Misses      13013    13016    +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -129,7 +129,8 @@ void ExampleStatusOr(google::cloud::pubsub_admin::TopicAdminClient client,
// The actual type of `topic` is
// google::cloud::StatusOr<google::pubsub::v1::Topic>, but
// we expect it'll most often be declared with auto like this.
for (auto& topic : client.ListTopics(project_id)) {
for (auto& topic :
Copy link
Member Author

Choose a reason for hiding this comment

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

This is an unrelated change, but I noticed it when I ran the auto version of samples

OptimisticSubscribe({project_id, topic_id, subscription_id});

std::cout << "\nRunning OptimisticSubscribe() sample [3]" << std::endl;
OptimisticSubscribe({project_id, topic_id, nonexistent_subscription_id});
Copy link
Member

Choose a reason for hiding this comment

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

good idea

return gc::Status();
}
if (response.status().code() == gc::StatusCode::kUnavailable &&
response.status().message() == "no messages returned") {
Copy link
Member

Choose a reason for hiding this comment

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

hm, I don't love that we are recommending code that parses an error message. We make no guarantees about the contents of the error message. It's ok, though.

optional, and not for this PR: This could be an opportunity for that client origin stuff. Something that feels more official?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah I agree... I think using IsClientOrigin would be better. I can refactor in a later PR.

@alevenberg alevenberg merged commit 7d7ff41 into googleapis:main May 23, 2024
63 checks passed
@alevenberg alevenberg deleted the opt branch May 23, 2024 16:28
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants