ClickHouse/programs/local/LocalServer.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

79 lines
2.3 KiB
C++
Raw Normal View History

#pragma once
2024-07-15 16:36:45 +00:00
#include <Client/ClientApplicationBase.h>
2021-08-17 19:59:51 +00:00
#include <Client/LocalConnection.h>
2021-07-23 20:54:49 +00:00
#include <Core/ServerSettings.h>
#include <Core/Settings.h>
#include <Interpreters/Context.h>
#include <Loggers/Loggers.h>
#include <Common/InterruptListener.h>
#include <Common/StatusFile.h>
2021-07-29 12:48:07 +00:00
#include <filesystem>
#include <memory>
#include <optional>
2021-07-23 20:54:49 +00:00
namespace DB
{
/// Lightweight Application for clickhouse-local
/// No networking, no extra configs and working directories, no pid and status files, no dictionaries, no logging.
/// Quiet mode by default
2024-07-15 16:36:45 +00:00
class LocalServer : public ClientApplicationBase, public Loggers
{
public:
2021-07-23 20:56:47 +00:00
LocalServer() = default;
2021-09-11 11:34:22 +00:00
2021-07-23 20:56:47 +00:00
void initialize(Poco::Util::Application & self) override;
2021-09-11 11:34:22 +00:00
2021-09-04 18:19:01 +00:00
int main(const std::vector<String> & /*args*/) override;
2021-07-23 20:56:47 +00:00
protected:
2024-06-25 14:23:37 +00:00
Poco::Util::LayeredConfiguration & getClientConfiguration() override;
2021-09-04 18:19:01 +00:00
void connect() override;
2022-03-14 11:00:47 +00:00
2021-08-19 11:07:47 +00:00
void processError(const String & query) const override;
2022-03-14 11:00:47 +00:00
2021-09-19 21:42:28 +00:00
String getName() const override { return "local"; }
2021-08-23 08:50:12 +00:00
void printHelpMessage(const OptionsDescription & options_description, bool verbose) override;
2021-07-28 12:56:11 +00:00
void addOptions(OptionsDescription & options_description) override;
2022-03-14 11:00:47 +00:00
2021-08-23 08:50:12 +00:00
void processOptions(const OptionsDescription & options_description, const CommandLineOptions & options,
const std::vector<Arguments> &, const std::vector<Arguments> &) override;
2022-03-14 11:00:47 +00:00
2021-07-29 12:48:07 +00:00
void processConfig() override;
2022-03-01 09:22:12 +00:00
void readArguments(int argc, char ** argv, Arguments & common_arguments, std::vector<Arguments> &, std::vector<Arguments> &) override;
2022-04-05 13:38:44 +00:00
void updateLoggerLevel(const String & logs_level) override;
2022-04-05 12:46:18 +00:00
private:
2021-07-23 20:56:47 +00:00
/** Composes CREATE subquery based on passed arguments (--structure --file --table and --input-format)
* This query will be executed first, before queries passed through --query argument
* Returns empty string if it cannot compose that query.
*/
std::string getInitialCreateTableQuery();
void tryInitPath();
void setupUsers();
void cleanup();
2021-08-19 11:07:47 +00:00
void applyCmdOptions(ContextMutablePtr context);
void applyCmdSettings(ContextMutablePtr context);
2021-02-07 17:32:45 +00:00
void createClientContext();
ServerSettings server_settings;
2021-07-23 20:54:49 +00:00
std::optional<StatusFile> status;
std::optional<std::filesystem::path> temporary_directory_to_delete;
std::unique_ptr<ReadBufferFromFile> input;
};
}