1 | #pragma once |
2 | |
3 | #include <Core/Types.h> |
4 | #include <unordered_map> |
5 | #include <Interpreters/IExternalLoaderConfigRepository.h> |
6 | #include <Poco/Timestamp.h> |
7 | |
8 | namespace DB |
9 | { |
10 | |
11 | /// XML config repository used by ExternalLoader. |
12 | /// Represents xml-files in local filesystem. |
13 | class ExternalLoaderXMLConfigRepository : public IExternalLoaderConfigRepository |
14 | { |
15 | public: |
16 | ExternalLoaderXMLConfigRepository(const Poco::Util::AbstractConfiguration & main_config_, const std::string & config_key_); |
17 | |
18 | const String & getName() const override { return name; } |
19 | |
20 | /// Return set of .xml files from path in main_config (config_key) |
21 | std::set<std::string> getAllLoadablesDefinitionNames() override; |
22 | |
23 | /// Checks that file with name exists on filesystem |
24 | bool exists(const std::string & definition_entity_name) override; |
25 | |
26 | /// Return xml-file modification time via stat call |
27 | Poco::Timestamp getUpdateTime(const std::string & definition_entity_name) override; |
28 | |
29 | /// May contain definition about several entities (several dictionaries in one .xml file) |
30 | LoadablesConfigurationPtr load(const std::string & definition_entity_name) override; |
31 | |
32 | private: |
33 | const String name; |
34 | |
35 | /// Main server config (config.xml). |
36 | const Poco::Util::AbstractConfiguration & main_config; |
37 | |
38 | /// Key which contains path to dicrectory with .xml configs for entries |
39 | std::string config_key; |
40 | }; |
41 | |
42 | } |
43 | |