-
Notifications
You must be signed in to change notification settings - Fork 373
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
Conversation
Here is the summary of changes. You are about to add 3 region tags.
This comment is generated by snippet-bot.
|
Codecov ReportPatch coverage:
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
☔ View full report in Codecov by Sentry. |
There was a problem hiding this 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] |
There was a problem hiding this comment.
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:
google-cloud-cpp/google/cloud/pubsub/samples/samples.cc
Lines 1400 to 1439 in facd5b4
//! [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:
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue #11720
This change is