ClickHouse/src/Server/GRPCServer.h

47 lines
987 B
C++
Raw Normal View History

2020-09-21 22:12:55 +00:00
#pragma once
2020-10-11 02:19:01 +00:00
#if !defined(ARCADIA_BUILD)
#include <Common/config.h>
#endif
2020-09-21 22:12:55 +00:00
2020-10-11 02:19:01 +00:00
#if USE_GRPC
#include <Poco/Runnable.h>
#include "clickhouse_grpc.grpc.pb.h"
2020-09-21 22:12:55 +00:00
2020-10-11 02:19:01 +00:00
namespace Poco { class Logger; }
2020-09-21 22:12:55 +00:00
2020-10-11 02:19:01 +00:00
namespace grpc
2020-09-21 22:12:55 +00:00
{
2020-10-11 02:19:01 +00:00
class Server;
class ServerCompletionQueue;
}
2020-09-21 22:12:55 +00:00
2020-10-11 02:19:01 +00:00
namespace DB
2020-09-21 22:12:55 +00:00
{
2020-10-11 02:19:01 +00:00
class IServer;
2020-09-21 22:12:55 +00:00
class GRPCServer final : public Poco::Runnable
{
2020-10-11 02:19:01 +00:00
public:
GRPCServer(const GRPCServer & handler) = delete;
GRPCServer(GRPCServer && handler) = delete;
GRPCServer(std::string address_to_listen_, IServer & server_);
~GRPCServer() override;
void stop();
virtual void run() override;
void HandleRpcs();
private:
using GRPCService = clickhouse::grpc::ClickHouse::AsyncService;
2020-10-11 02:19:01 +00:00
IServer & iserver;
Poco::Logger * log;
std::unique_ptr<grpc::ServerCompletionQueue> notification_cq;
std::unique_ptr<grpc::ServerCompletionQueue> new_call_cq;
GRPCService grpc_service;
2020-10-11 02:19:01 +00:00
std::unique_ptr<grpc::Server> grpc_server;
std::string address_to_listen;
2020-09-21 22:12:55 +00:00
};
2020-10-11 02:19:01 +00:00
}
#endif