Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/151.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;_C++_Asynchronous_Google Cloud Platform_Grpc_Google Cloud Pubsub - Fatal编程技术网

C++ C++;

C++ C++;,c++,asynchronous,google-cloud-platform,grpc,google-cloud-pubsub,C++,Asynchronous,Google Cloud Platform,Grpc,Google Cloud Pubsub,我试图找到一个关于在异步grpc上使用Pubsub流式API的文档,但找不到任何文档 我有一个简单的代码来读取主题中的所有消息: auto creds = grpc::GoogleDefaultCredentials(); auto stub = std::make_unique<Subscriber::Stub>( grpc::CreateChannel("pubsub.googleapis.com", creds)); Clien

我试图找到一个关于在异步grpc上使用Pubsub流式API的文档,但找不到任何文档

我有一个简单的代码来读取主题中的所有消息:

  auto creds = grpc::GoogleDefaultCredentials();
  auto stub = std::make_unique<Subscriber::Stub>(
        grpc::CreateChannel("pubsub.googleapis.com", creds));

  ClientContext context;
  std::unique_ptr<ClientReaderWriter<
      StreamingPullRequest, StreamingPullResponse>> stream(
          stub->StreamingPull(&context));

  StreamingPullRequest request;
  request.set_subscription(
      "projects/test/subscriptions/test-subscription");
  request.set_stream_ack_deadline_seconds(10);
  stream->Write(request);

  StreamingPullResponse response;
  while (stream->Read(&response)) {
    StreamingPullRequest ack_request;
    for (const auto &message : response.received_messages()) {
      ack_request.add_ack_ids(message.ack_id());
    }
    stream->Write(ack_request);
  }

你能帮我一个简单的异步代码的例子吗?

目前谷歌云平台C++库还没有被厂商正式宣布,而且没有实现的ETA,因此代码库作为一个概念证明存在,仍然没有完整的文档,没有正确的用法示例。您可以跟踪社区的努力,以便遵循Github线程进行进一步的库开发

据我所知,您正在寻找通过异步调用执行的任何洞察,回顾@ Manuel Menzella发布的信息,我建议您检查一下他的方法,它可以在概念上适合您的用例。

< P>目前谷歌云平台C++库还没有被厂商正式宣布,也没有ETAS实现。因此,代码库作为概念证明而存在,并且仍然没有完整的文档记录,没有合适的使用示例。您可以跟踪社区的努力,以便遵循Github线程进行进一步的库开发

据我所知,您正在寻找通过异步调用执行的任何洞察,回顾@Manuel Menzella发布的文章,我建议您查看他的方法,该方法在概念上适合您的用例

    StreamingPullRequest ack_request;
    for (const auto &message : response.received_messages()) {
      ack_request.add_ack_ids(message.ack_id());
    }
    stream->Write(ack_request);