google/cloud/pubsub/samples/samples.cc
// This is a helper function to publish N messages later consumed by another
// example.
This is a helper function to publish N messages later consumed by another
example.
This is a helper function to publish N messages later consumed by another example .
void PublishHelper(google::cloud::pubsub::Publisher publisher,
                   std::string const& prefix, int message_count) {
  namespace pubsub = google::cloud::pubsub;
  using google::cloud::future;
  using google::cloud::StatusOr;
  std::vector<future<StatusOr<std::string>>> done;
  done.reserve(message_count);
  for (int i = 0; i != message_count; ++i) {
    std::string const value = i % 2 == 0 ? "true" : "false";
    done.push_back(
        publisher.Publish(pubsub::MessageBuilder{}
                              .SetAttribute("is-even", value)
                              .SetData(prefix + " [" + std::to_string(i) + "]")
                              .Build()));
  }
  publisher.Flush();
  for (auto& f : done) f.get();
}
void PublishHelper ( google :: cloud :: pubsub :: Publisher publisher , std :: string const & prefix , int message_count ) { namespace pubsub = google :: cloud :: pubsub ; using google :: cloud :: future ; using google :: cloud :: StatusOr ; std :: vector < future < StatusOr < std :: string > > > done ; done . reserve ( message_count ) ; for ( int i = 0 ; i != message_count ; ++ i ) { std :: string const value = i % 2 == 0 ? " " : " " ; done . push_back ( publisher . Publish ( pubsub :: MessageBuilder { } . SetAttribute ( " " , value ) . SetData ( prefix + " " + std :: to_string ( i ) + " " ) . Build ( ) ) ) ; } publisher . Flush ( ) ; for ( auto & f : done ) f . get ( ) ; }
This is a helper function to publish N messages later consumed by another
example.
This is a helper function to publish N messages later consumed by another example .