aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Interpreters/ExternalLoaderXMLConfigRepository.h
blob: 25646d72db3ec5c1c8c3b78e473e3653aa41dd5c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once

#include <base/types.h>
#include <unordered_set>
#include <mutex>
#include <Interpreters/IExternalLoaderConfigRepository.h>
#include <Poco/Timestamp.h>


namespace DB
{

/// XML config repository used by ExternalLoader.
/// Represents xml-files in local filesystem.
class ExternalLoaderXMLConfigRepository : public IExternalLoaderConfigRepository
{
public:
    ExternalLoaderXMLConfigRepository(const std::string & app_path_, const std::string & main_config_path_, const std::unordered_set<std::string> & patterns_);

    std::string getName() const override { return name; }

    /// Return set of .xml files from path in main_config (config_key)
    std::set<std::string> getAllLoadablesDefinitionNames() override;

    /// Checks that file with name exists on filesystem
    bool exists(const std::string & definition_entity_name) override;

    /// Return xml-file modification time via stat call
    Poco::Timestamp getUpdateTime(const std::string & definition_entity_name) override;

    /// May contain definition about several entities (several dictionaries in one .xml file)
    LoadablesConfigurationPtr load(const std::string & config_file) override;

    void updatePatterns(const std::unordered_set<std::string> & patterns_);

private:

    const String name;

    const std::string app_path;

    const std::string main_config_path;

    std::unordered_set<std::string> patterns;

    mutable std::mutex patterns_mutex;

};

}