2017-10-06 11:10:01 +00:00
|
|
|
#pragma once
|
2017-10-06 10:31:06 +00:00
|
|
|
#include <string>
|
|
|
|
#include <memory>
|
2017-10-06 11:10:01 +00:00
|
|
|
#include <Core/Types.h>
|
2017-10-06 10:31:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace Poco::Util
|
|
|
|
{
|
2017-10-06 11:10:01 +00:00
|
|
|
class AbstractConfiguration;
|
2017-10-06 10:31:06 +00:00
|
|
|
}
|
|
|
|
|
2017-10-06 11:10:01 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
/// Min and max lifetimes for a loadable object or it's entry
|
|
|
|
struct ExternalLoadableLifetime final
|
|
|
|
{
|
|
|
|
UInt64 min_sec;
|
|
|
|
UInt64 max_sec;
|
|
|
|
|
|
|
|
ExternalLoadableLifetime(const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix);
|
|
|
|
};
|
|
|
|
|
2017-10-26 18:30:28 +00:00
|
|
|
|
|
|
|
/// Basic interface for external loadable objects. Is used in ExternalLoader.
|
2017-10-06 10:31:06 +00:00
|
|
|
class IExternalLoadable : public std::enable_shared_from_this<IExternalLoadable>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~IExternalLoadable() = default;
|
|
|
|
|
|
|
|
virtual const ExternalLoadableLifetime & getLifetime() const = 0;
|
|
|
|
|
|
|
|
virtual std::string getName() const = 0;
|
2017-10-26 18:30:28 +00:00
|
|
|
/// True if object can be updated when lifetime exceeded.
|
2017-10-06 10:31:06 +00:00
|
|
|
virtual bool supportUpdates() const = 0;
|
2017-10-26 18:30:28 +00:00
|
|
|
/// If lifetime exceeded and isModified() ExternalLoader replace current object with the result of clone().
|
2017-10-06 10:31:06 +00:00
|
|
|
virtual bool isModified() const = 0;
|
2017-10-26 18:30:28 +00:00
|
|
|
/// Returns new object with the same configuration. Is used to update modified object when lifetime exceeded.
|
2017-10-26 13:36:01 +00:00
|
|
|
virtual std::unique_ptr<IExternalLoadable> clone() const = 0;
|
2017-10-06 10:31:06 +00:00
|
|
|
|
|
|
|
virtual std::exception_ptr getCreationException() const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|