2019-09-30 16:12:08 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-10-02 07:13:14 +00:00
|
|
|
#include <base/types.h>
|
2021-09-29 12:52:58 +00:00
|
|
|
#include <unordered_set>
|
|
|
|
#include <mutex>
|
2019-09-30 16:12:08 +00:00
|
|
|
#include <Interpreters/IExternalLoaderConfigRepository.h>
|
|
|
|
#include <Poco/Timestamp.h>
|
|
|
|
|
2021-09-29 12:52:58 +00:00
|
|
|
|
2019-09-30 16:12:08 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/// XML config repository used by ExternalLoader.
|
|
|
|
/// Represents xml-files in local filesystem.
|
|
|
|
class ExternalLoaderXMLConfigRepository : public IExternalLoaderConfigRepository
|
|
|
|
{
|
|
|
|
public:
|
2021-09-29 12:52:58 +00:00
|
|
|
ExternalLoaderXMLConfigRepository(const std::string & app_path_, const std::string & main_config_path_, const std::unordered_set<std::string> & patterns_);
|
2019-09-30 16:12:08 +00:00
|
|
|
|
2021-04-22 07:53:44 +00:00
|
|
|
std::string getName() const override { return name; }
|
2019-09-30 16:12:08 +00:00
|
|
|
|
2019-09-30 16:54:50 +00:00
|
|
|
/// Return set of .xml files from path in main_config (config_key)
|
2019-12-30 23:30:06 +00:00
|
|
|
std::set<std::string> getAllLoadablesDefinitionNames() override;
|
2019-09-30 16:12:08 +00:00
|
|
|
|
2019-09-30 16:54:50 +00:00
|
|
|
/// Checks that file with name exists on filesystem
|
2019-12-30 23:30:06 +00:00
|
|
|
bool exists(const std::string & definition_entity_name) override;
|
2019-09-30 16:12:08 +00:00
|
|
|
|
2019-10-01 08:58:47 +00:00
|
|
|
/// Return xml-file modification time via stat call
|
|
|
|
Poco::Timestamp getUpdateTime(const std::string & definition_entity_name) override;
|
2019-09-30 16:12:08 +00:00
|
|
|
|
|
|
|
/// May contain definition about several entities (several dictionaries in one .xml file)
|
2020-03-09 00:08:02 +00:00
|
|
|
LoadablesConfigurationPtr load(const std::string & config_file) override;
|
2019-09-30 16:12:08 +00:00
|
|
|
|
2021-09-29 12:52:58 +00:00
|
|
|
void updatePatterns(const std::unordered_set<std::string> & patterns_);
|
|
|
|
|
2019-09-30 16:12:08 +00:00
|
|
|
private:
|
2021-09-29 12:52:58 +00:00
|
|
|
|
2019-12-30 23:30:06 +00:00
|
|
|
const String name;
|
|
|
|
|
2021-09-29 12:52:58 +00:00
|
|
|
const std::string app_path;
|
|
|
|
|
|
|
|
const std::string main_config_path;
|
|
|
|
|
|
|
|
std::unordered_set<std::string> patterns;
|
|
|
|
|
|
|
|
mutable std::mutex patterns_mutex;
|
2019-09-30 16:12:08 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|