ClickHouse/src/Bridge/IBridge.h

52 lines
1.3 KiB
C++
Raw Normal View History

2021-03-07 13:55:40 +00:00
#pragma once
#include <Interpreters/Context.h>
#include <Server/HTTP/HTTPRequestHandlerFactory.h>
2022-04-27 15:05:45 +00:00
#include <Daemon/BaseDaemon.h>
2021-03-07 13:55:40 +00:00
#include <Poco/Logger.h>
#include <Poco/Util/ServerApplication.h>
2021-03-07 13:55:40 +00:00
namespace DB
{
/// Class represents base for clickhouse-odbc-bridge and clickhouse-library-bridge servers.
/// Listens to incoming HTTP POST and GET requests on specified port and host.
/// Has two handlers '/' for all incoming POST requests and /ping for GET request about service status.
class IBridge : public BaseDaemon
{
public:
2021-03-23 05:41:21 +00:00
/// Define command line arguments
2021-03-07 13:55:40 +00:00
void defineOptions(Poco::Util::OptionSet & options) override;
protected:
using HandlerFactoryPtr = std::shared_ptr<HTTPRequestHandlerFactory>;
void initialize(Application & self) override;
void uninitialize() override;
int main(const std::vector<std::string> & args) override;
virtual std::string bridgeName() const = 0;
2021-03-07 13:55:40 +00:00
virtual HandlerFactoryPtr getHandlerFactoryPtr(ContextPtr context) const = 0;
2021-03-07 13:55:40 +00:00
size_t keep_alive_timeout;
private:
void handleHelp(const std::string &, const std::string &);
bool is_help;
std::string hostname;
size_t port;
std::string log_level;
size_t max_server_connections;
size_t http_timeout;
Poco::Logger * log;
};
}