diff --git a/CMakeLists.txt b/CMakeLists.txt index d4290eb37..5bee7af4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,6 +121,8 @@ add_subdirectory(libs) set(fmt_source_dir ${libs_dir}/fmt) set(fmt_static_lib ${fmt_source_dir}/fmt/libfmt.a) # yaml-cpp +# We no longer use yaml for configuration reading, maybe this dependancy should +# be removed. It is only used in tests/benchmark/query/strip/stripper.cpp set(yaml_source_dir ${libs_dir}/yaml-cpp) set(yaml_include_dir ${yaml_source_dir}/include) set(yaml_static_lib ${yaml_source_dir}/libyaml-cpp.a) diff --git a/src/config/config.cpp b/src/config/config.cpp deleted file mode 100644 index 891745878..000000000 --- a/src/config/config.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "config/config.hpp" - -namespace config { - -const char *MemgraphConfig::env_config_key = "MEMGRAPH_CONFIG"; -const char *MemgraphConfig::default_file_path = "/etc/memgraph/config.yaml"; - -// configuration for arguments which can be passed threw command line -// TODO add support for shortened names -// Example: -// --cleaning_cycle_sec or -ccs, etc. -std::set<std::string> MemgraphConfig::arguments = { - "cleaning_cycle_sec", "snapshot_cycle_sec", -}; -} diff --git a/src/utils/config/config.hpp b/src/utils/config/config.hpp deleted file mode 100644 index 1644c6cd7..000000000 --- a/src/utils/config/config.hpp +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include <cstdlib> -#include <cstring> -#include <iostream> -#include <stdexcept> -#include <string> - -#include <pwd.h> -#include <sys/types.h> -#include <unistd.h> - -// TODO: isolate from caller (caller shouldn't know that his dependency is) -// yaml-cpp -#include "utils/command_line/arguments.hpp" -#include "yaml-cpp/yaml.h" - -namespace config { - -template <class Definition> -class Config { - private: - using KeyValueMap = std::map<std::string, std::string>; - - KeyValueMap dict; - - void load_configuration(std::string path) { - try { - YAML::Node node = YAML::LoadFile(path); - - for (YAML::const_iterator it = node.begin(); it != node.end(); ++it) { - dict[it->first.as<std::string>()] = it->second.as<std::string>(); - } - } catch (std::exception ex) { - // configuration doesn't exist or invalid!!! - } - } - - Config() { - // config places: priority - // 1. default system | (/etc/memgraph/config) - // 2. default user | (/home/user/.memgraph/config) - // 3. ENV var | (PATH) - // 4. program argument \ / (PATH) - - // default system configuration - load_configuration(Definition::default_file_path); - - // default user configuration - // fetches user configuration folder - std::string homedir = std::getenv("HOME"); - if ((homedir == "")) { - homedir = getpwuid(getuid())->pw_dir; - } - homedir += "/.memgraph/config.yaml"; - load_configuration(homedir); - - // environment variable configuratoin - if (const char *env_path = std::getenv(Definition::env_config_key)) - load_configuration(env_path); - } - - public: - static Config<Definition> &instance() { - static Config<Definition> config; - return config; - } - - void register_args(int argc, char **argv) { - REGISTER_ARGS(argc, argv); - - for (const auto &argument : Definition::arguments) { - dict[argument] = GET_ARG("--" + argument, dict[argument]).get_string(); - } - } - - std::string &operator[](const char *key) { return dict[key]; } -}; -}