1 | #pragma once |
---|---|
2 | #include <Interpreters/Context.h> |
3 | #include <Poco/Logger.h> |
4 | #include <Poco/Net/HTTPRequestHandler.h> |
5 | #include <Poco/Net/HTTPRequestHandlerFactory.h> |
6 | #include "MainHandler.h" |
7 | #include "ColumnInfoHandler.h" |
8 | #include "IdentifierQuoteHandler.h" |
9 | |
10 | #pragma GCC diagnostic push |
11 | #pragma GCC diagnostic ignored "-Wunused-parameter" |
12 | #include <Poco/Data/SessionPool.h> |
13 | #pragma GCC diagnostic pop |
14 | |
15 | |
16 | namespace DB |
17 | { |
18 | /** Factory for '/ping', '/', '/columns_info', '/identifier_quote' handlers. |
19 | * Also stores Session pools for ODBC connections |
20 | */ |
21 | class HandlerFactory : public Poco::Net::HTTPRequestHandlerFactory |
22 | { |
23 | public: |
24 | HandlerFactory(const std::string & name_, size_t keep_alive_timeout_, std::shared_ptr<Context> context_) |
25 | : log(&Poco::Logger::get(name_)), name(name_), keep_alive_timeout(keep_alive_timeout_), context(context_) |
26 | { |
27 | pool_map = std::make_shared<ODBCHandler::PoolMap>(); |
28 | } |
29 | |
30 | Poco::Net::HTTPRequestHandler * createRequestHandler(const Poco::Net::HTTPServerRequest & request) override; |
31 | |
32 | private: |
33 | Poco::Logger * log; |
34 | std::string name; |
35 | size_t keep_alive_timeout; |
36 | std::shared_ptr<Context> context; |
37 | std::shared_ptr<ODBCHandler::PoolMap> pool_map; |
38 | }; |
39 | } |
40 |