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

fix(pubsub): add commit schema and list schema revision samples #11840

Merged
merged 6 commits into from
Jun 9, 2023

Conversation

alevenberg
Copy link
Member

@alevenberg alevenberg commented Jun 9, 2023

Issue #11720


This change is Reviewable

@alevenberg alevenberg requested a review from a team as a code owner June 9, 2023 17:18
@snippet-bot
Copy link

snippet-bot bot commented Jun 9, 2023

Here is the summary of changes.

You are about to add 3 region tags.

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

@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 Jun 9, 2023
@codecov
Copy link

codecov bot commented Jun 9, 2023

Codecov Report

Patch coverage: 61.81% and project coverage change: +0.01 🎉

Comparison is base (0754b6e) 93.78% compared to head (b1f4885) 93.79%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11840      +/-   ##
==========================================
+ Coverage   93.78%   93.79%   +0.01%     
==========================================
  Files        1838     1838              
  Lines      166295   166350      +55     
==========================================
+ Hits       155956   156032      +76     
+ Misses      10339    10318      -21     
Impacted Files Coverage Δ
google/cloud/pubsub/samples/samples.cc 87.20% <61.81%> (-1.05%) ⬇️

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@alevenberg alevenberg merged commit 0b7b9b6 into googleapis:main Jun 9, 2023
@alevenberg alevenberg deleted the issue-11720 branch June 9, 2023 18:21
Copy link
Member

@dbolduc dbolduc left a comment

Choose a reason for hiding this comment

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

nit: This type of PR should be a doc(pubsub) instead of a fix(pubsub).

(Oops, I am too late on the review. It's not a big deal. Just use doc for the next one).

@@ -834,6 +835,65 @@ void CreateProtobufSchema(google::cloud::pubsub::SchemaServiceClient client,
(std::move(client), argv.at(0), argv.at(1), argv.at(2));
}

void CommitAvroSchema(google::cloud::pubsub::SchemaServiceClient client,
std::vector<std::string> const& argv) {
//! [START pubsub_commit_avro_schema] [commit-avro-schema]
Copy link
Member

Choose a reason for hiding this comment

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

FYI: The second tag is unnecessary and can be removed. (unless you plan to write a doc that links it). Here's why...


There are two types of tags for samples.

The first tag [START pubsub_commit_avro_schema] is used by the DevRel teams. These tags denote samples that show up on https://cloud.google.com/pubsub/docs/samples (for example).

The second tag, [commit-avro-schema], is something our team uses to include samples in our documentation.

For example, the google::cloud::pubsub::Publisher:

* @snippet samples.cc custom-thread-pool-publisher

.... links to this sample:

//! [custom-thread-pool-publisher]
namespace pubsub = ::google::cloud::pubsub;
using ::google::cloud::future;
using ::google::cloud::GrpcCompletionQueueOption;
using ::google::cloud::Options;
using ::google::cloud::StatusOr;
[](std::string project_id, std::string topic_id) {
// Create our own completion queue to run the background activity, such as
// flushing the publisher.
google::cloud::CompletionQueue cq;
// Setup one or more of threads to service this completion queue. These must
// remain running until all the work is done.
std::vector<std::thread> tasks;
std::generate_n(std::back_inserter(tasks), 4, [&cq] {
return std::thread([cq]() mutable { cq.Run(); });
});
auto topic = pubsub::Topic(std::move(project_id), std::move(topic_id));
auto publisher = pubsub::Publisher(pubsub::MakePublisherConnection(
std::move(topic), Options{}.set<GrpcCompletionQueueOption>(cq)));
std::vector<future<void>> ids;
for (char const* data : {"1", "2", "3", "go!"}) {
ids.push_back(
publisher.Publish(pubsub::MessageBuilder().SetData(data).Build())
.then([data](future<StatusOr<std::string>> f) {
auto s = f.get();
if (!s) return;
std::cout << "Sent '" << data << "' (" << *s << ")\n";
}));
}
publisher.Flush();
// Block until they are actually sent.
for (auto& id : ids) id.get();
// Shutdown the completion queue and join the threads
cq.Shutdown();
for (auto& t : tasks) t.join();
}
//! [custom-thread-pool-publisher]

... which results in the following documentation:

https://cloud.google.com/cpp/docs/reference/pubsub/latest/classgoogle_1_1cloud_1_1pubsub_1_1Publisher#example-using-a-custom-thread-pool

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah i see will send a PR to fix

Copy link

@0000854453 0000854453 left a comment

Choose a reason for hiding this comment

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

@googleapis googleapis deleted a comment from 0000854453 Jun 23, 2023
@googleapis googleapis deleted a comment from 0000854453 Jun 23, 2023
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.

4 participants