2021-03-07 13:55:40 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Interpreters/Context.h>
|
|
|
|
#include <Server/HTTP/HTTPRequestHandlerFactory.h>
|
|
|
|
#include <daemon/BaseDaemon.h>
|
|
|
|
|
2021-04-10 23:33:54 +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;
|
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
virtual std::string bridgeName() const = 0;
|
2021-03-07 13:55:40 +00:00
|
|
|
|
2021-04-10 23:33:54 +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;
|
|
|
|
};
|
|
|
|
}
|