aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Functions/UserDefined/ExternalUserDefinedExecutableFunctionsLoader.h
blob: 1a62175eb0ccd9aeb6f8e38fa973e4065b975e3a (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
#pragma once

#include <memory>

#include <Interpreters/Context_fwd.h>
#include <Interpreters/ExternalLoader.h>
#include <Functions/UserDefined/UserDefinedExecutableFunction.h>

namespace DB
{

class IExternalLoaderConfigRepository;

/// Manages external user-defined functions.
class ExternalUserDefinedExecutableFunctionsLoader : public ExternalLoader, WithContext
{
public:

    using UserDefinedExecutableFunctionPtr = std::shared_ptr<const UserDefinedExecutableFunction>;

    /// External user-defined functions will be loaded immediately and then will be updated in separate thread, each 'reload_period' seconds.
    explicit ExternalUserDefinedExecutableFunctionsLoader(ContextPtr global_context_);

    UserDefinedExecutableFunctionPtr getUserDefinedFunction(const std::string & user_defined_function_name) const;

    UserDefinedExecutableFunctionPtr tryGetUserDefinedFunction(const std::string & user_defined_function_name) const;

    void reloadFunction(const std::string & user_defined_function_name) const;

protected:
    LoadablePtr create(const std::string & name,
        const Poco::Util::AbstractConfiguration & config,
        const std::string & key_in_config,
        const std::string & repository_name) const override;

};

}