This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <grpc++/grpc++.h> | |
#include <grpc++/security/credentials.h> | |
#include "pubsub.grpc.pb.h" | |
int main(int argc, char** argv) { | |
auto channel = grpc::CreateChannel(“pubsub.googleapis.com”, grpc::GoogleDefaultCredentials()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code sample. May need minor fixes to compile. | |
// Create a sync service handling class | |
class OpenConfigImpl : public openconfigs::OpenConfig::Service { | |
public: | |
::grpc::Status::Subscribe(::grpc::ServerContext* context, ::grpc::ServerReaderWriter<SubscribeResponse, SubscribeRequest>* stream) override; | |
::grpc::Status::Set(::grpc::ServerContext* context, ::grpc::ServerReaderWriter<SetResponse, SetRequest>* stream) override; | |
// Get will be handled async. | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Class encompasing the state and logic needed to serve a request. | |
class CallDataBase { | |
public: | |
// Take in the "service" instance (in this case representing an asynchronous | |
// server) and the completion queue "cq" used for asynchronous communication | |
// with the gRPC runtime. | |
CallDataBase(Greeter::AsyncService* service, ServerCompletionQueue* cq) | |
: service_(service), cq_(cq), status_(PROCESS) {} | |
virtual ~CallDataBase() {} |