| 1 | #pragma once |
|---|---|
| 2 | |
| 3 | #include "IServer.h" |
| 4 | |
| 5 | #include <daemon/BaseDaemon.h> |
| 6 | |
| 7 | /** Server provides three interfaces: |
| 8 | * 1. HTTP - simple interface for any applications. |
| 9 | * 2. TCP - interface for native clickhouse-client and for server to server internal communications. |
| 10 | * More rich and efficient, but less compatible |
| 11 | * - data is transferred by columns; |
| 12 | * - data is transferred compressed; |
| 13 | * Allows to get more information in response. |
| 14 | * 3. Interserver HTTP - for replication. |
| 15 | */ |
| 16 | |
| 17 | |
| 18 | namespace DB |
| 19 | { |
| 20 | |
| 21 | class Server : public BaseDaemon, public IServer |
| 22 | { |
| 23 | public: |
| 24 | using ServerApplication::run; |
| 25 | |
| 26 | Poco::Util::LayeredConfiguration & config() const override |
| 27 | { |
| 28 | return BaseDaemon::config(); |
| 29 | } |
| 30 | |
| 31 | Poco::Logger & logger() const override |
| 32 | { |
| 33 | return BaseDaemon::logger(); |
| 34 | } |
| 35 | |
| 36 | Context & context() const override |
| 37 | { |
| 38 | return *global_context; |
| 39 | } |
| 40 | |
| 41 | bool isCancelled() const override |
| 42 | { |
| 43 | return BaseDaemon::isCancelled(); |
| 44 | } |
| 45 | |
| 46 | void defineOptions(Poco::Util::OptionSet & _options) override; |
| 47 | protected: |
| 48 | int run() override; |
| 49 | |
| 50 | void initialize(Application & self) override; |
| 51 | |
| 52 | void uninitialize() override; |
| 53 | |
| 54 | int main(const std::vector<std::string> & args) override; |
| 55 | |
| 56 | std::string getDefaultCorePath() const override; |
| 57 | |
| 58 | private: |
| 59 | std::unique_ptr<Context> global_context; |
| 60 | }; |
| 61 | |
| 62 | } |
| 63 |