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:
|
2020-10-05 20:33:34 +00:00
|
|
|
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;
|
2020-10-05 20:33:34 +00:00
|
|
|
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
|