mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 09:02:00 +00:00
495c6e03aa
* Replace all Context references with std::weak_ptr * Fix shared context captured by value * Fix build * Fix Context with named sessions * Fix copy context * Fix gcc build * Merge with master and fix build * Fix gcc-9 build
75 lines
1.7 KiB
C++
75 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <Server/IServer.h>
|
|
|
|
#include <daemon/BaseDaemon.h>
|
|
|
|
/** Server provides three interfaces:
|
|
* 1. HTTP - simple interface for any applications.
|
|
* 2. TCP - interface for native clickhouse-client and for server to server internal communications.
|
|
* More rich and efficient, but less compatible
|
|
* - data is transferred by columns;
|
|
* - data is transferred compressed;
|
|
* Allows to get more information in response.
|
|
* 3. Interserver HTTP - for replication.
|
|
*/
|
|
|
|
namespace Poco
|
|
{
|
|
namespace Net
|
|
{
|
|
class ServerSocket;
|
|
}
|
|
}
|
|
|
|
namespace DB
|
|
{
|
|
|
|
class Server : public BaseDaemon, public IServer
|
|
{
|
|
public:
|
|
using ServerApplication::run;
|
|
|
|
Poco::Util::LayeredConfiguration & config() const override
|
|
{
|
|
return BaseDaemon::config();
|
|
}
|
|
|
|
Poco::Logger & logger() const override
|
|
{
|
|
return BaseDaemon::logger();
|
|
}
|
|
|
|
ContextPtr context() const override
|
|
{
|
|
return global_context;
|
|
}
|
|
|
|
bool isCancelled() const override
|
|
{
|
|
return BaseDaemon::isCancelled();
|
|
}
|
|
|
|
void defineOptions(Poco::Util::OptionSet & _options) override;
|
|
|
|
protected:
|
|
int run() override;
|
|
|
|
void initialize(Application & self) override;
|
|
|
|
void uninitialize() override;
|
|
|
|
int main(const std::vector<std::string> & args) override;
|
|
|
|
std::string getDefaultCorePath() const override;
|
|
|
|
private:
|
|
ContextPtr global_context;
|
|
Poco::Net::SocketAddress socketBindListen(Poco::Net::ServerSocket & socket, const std::string & host, UInt16 port, [[maybe_unused]] bool secure = false) const;
|
|
|
|
using CreateServerFunc = std::function<void(UInt16)>;
|
|
void createServer(const std::string & listen_host, const char * port_name, bool listen_try, CreateServerFunc && func) const;
|
|
};
|
|
|
|
}
|