clickhouse connection operational
This commit is contained in:
11
src/main.cpp
11
src/main.cpp
@@ -1,17 +1,26 @@
|
||||
#include "clickhouse/client.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <sys/types.h>
|
||||
#include <toml++/toml.h>
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
auto config = toml::parse_file("config.toml");
|
||||
bool ingest_all_logs = config["all"].value_or(false);
|
||||
std::string user_id = config["user_id"].value_or("kid");
|
||||
std::string log_path = config["minecraft"]["logs_path"].value_or("");
|
||||
if(log_path.empty()) throw std::runtime_error("your dumbass can't put in a path");
|
||||
std::string clickhouse_username = config["clickhouse"]["username"].value_or("");
|
||||
std::string clickouse_password = config["clickhouse"]["password"].value_or("");
|
||||
std::string clickhouse_db = config["clickhouse"]["db"].value_or("");
|
||||
if(clickhouse_username.empty() || clickouse_password.empty() || clickhouse_db.empty()) throw std::runtime_error("put the creds in the right place idiot");
|
||||
std::string clickhouse_host = config["clickhouse"]["host"].value_or("");
|
||||
uint clickhouse_port = config["clickhouse"]["port"].value_or(9000);
|
||||
if(clickhouse_username.empty() || clickouse_password.empty() || clickhouse_db.empty() || clickhouse_host.empty()) throw std::runtime_error("put the creds in the right place idiot");
|
||||
|
||||
spdlog::info("Logging is functional");
|
||||
|
||||
std::shared_ptr<clickhouse::Client> shared_client = std::make_shared<clickhouse::Client>(clickhouse::ClientOptions().SetPassword(clickouse_password).SetDefaultDatabase(clickhouse_db).SetUser(clickhouse_username).SetHost(clickhouse_host).SetPort(clickhouse_port));
|
||||
spdlog::info("Server connection: {}", shared_client->GetServerInfo().display_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user