-
Notifications
You must be signed in to change notification settings - Fork 0
/
GrpcServer.hpp
37 lines (29 loc) · 910 Bytes
/
GrpcServer.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef GRPC_SERVER_HPP
#define GRPC_SERVER_HPP
#include <grpcpp/grpcpp.h>
#include <memory>
#include "GrpcServerCallData.hpp"
class GrpcServer {
public:
GrpcServer();
~GrpcServer();
void addListeningPort(
const std::string &address,
const std::shared_ptr<grpc::ServerCredentials> &credentials);
void registerService(grpc::Service *service);
void buildAndStart();
template <class Service, class Call, class Reply>
void requestCallFromService(
Service &service,
const typename GrpcServerCallData<Service, Call, Reply>::CallRequest
&request,
const typename GrpcServerCallData<Service, Call, Reply>::CallHandler
&handler);
void startHandlingCalls();
private:
grpc::ServerBuilder m_builder;
std::unique_ptr<grpc::ServerCompletionQueue> m_completionQueue;
std::unique_ptr<grpc::Server> m_server;
};
#include "GrpcServer.impl"
#endif