2020-06-01 17:16:09 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
|
|
|
#include <mutex>
|
2020-12-10 09:19:42 +00:00
|
|
|
#include <optional>
|
2020-09-15 09:55:57 +00:00
|
|
|
#include <vector>
|
2021-10-02 07:13:14 +00:00
|
|
|
#include <base/types.h>
|
2022-04-03 22:33:59 +00:00
|
|
|
#include <Interpreters/Context_fwd.h>
|
2020-06-01 17:16:09 +00:00
|
|
|
|
|
|
|
namespace Poco::Util
|
|
|
|
{
|
|
|
|
class AbstractConfiguration;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
struct HttpHeader
|
|
|
|
{
|
2021-03-04 15:56:55 +00:00
|
|
|
String name;
|
|
|
|
String value;
|
|
|
|
|
|
|
|
inline bool operator==(const HttpHeader & other) const { return name == other.name && value == other.value; }
|
2020-06-01 17:16:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
using HeaderCollection = std::vector<HttpHeader>;
|
|
|
|
|
2022-04-03 22:33:59 +00:00
|
|
|
struct Settings;
|
|
|
|
|
|
|
|
struct S3Settings
|
2020-06-01 17:16:09 +00:00
|
|
|
{
|
2022-04-03 22:33:59 +00:00
|
|
|
struct AuthSettings
|
|
|
|
{
|
|
|
|
String access_key_id;
|
|
|
|
String secret_access_key;
|
|
|
|
String region;
|
|
|
|
String server_side_encryption_customer_key_base64;
|
2020-06-01 17:16:09 +00:00
|
|
|
|
2022-04-03 22:33:59 +00:00
|
|
|
HeaderCollection headers;
|
2020-12-10 09:19:42 +00:00
|
|
|
|
2022-04-03 22:33:59 +00:00
|
|
|
std::optional<bool> use_environment_credentials;
|
|
|
|
std::optional<bool> use_insecure_imds_request;
|
2021-03-04 15:56:55 +00:00
|
|
|
|
2022-04-03 22:33:59 +00:00
|
|
|
inline bool operator==(const AuthSettings & other) const
|
|
|
|
{
|
|
|
|
return access_key_id == other.access_key_id && secret_access_key == other.secret_access_key
|
|
|
|
&& region == other.region
|
|
|
|
&& server_side_encryption_customer_key_base64 == other.server_side_encryption_customer_key_base64
|
|
|
|
&& headers == other.headers
|
|
|
|
&& use_environment_credentials == other.use_environment_credentials
|
|
|
|
&& use_insecure_imds_request == other.use_insecure_imds_request;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ReadWriteSettings
|
2021-03-04 15:56:55 +00:00
|
|
|
{
|
2022-04-03 22:33:59 +00:00
|
|
|
size_t max_single_read_retries = 0;
|
|
|
|
size_t min_upload_part_size = 0;
|
|
|
|
size_t upload_part_size_multiply_factor = 0;
|
|
|
|
size_t upload_part_size_multiply_parts_count_threshold = 0;
|
|
|
|
size_t max_single_part_upload_size = 0;
|
|
|
|
size_t max_connections = 0;
|
2022-08-23 13:12:09 +00:00
|
|
|
bool check_objects_after_upload = false;
|
2022-04-06 20:27:38 +00:00
|
|
|
|
|
|
|
ReadWriteSettings() = default;
|
|
|
|
explicit ReadWriteSettings(const Settings & settings);
|
|
|
|
|
|
|
|
inline bool operator==(const ReadWriteSettings & other) const
|
|
|
|
{
|
|
|
|
return max_single_read_retries == other.max_single_read_retries
|
|
|
|
&& min_upload_part_size == other.min_upload_part_size
|
|
|
|
&& upload_part_size_multiply_factor == other.upload_part_size_multiply_factor
|
|
|
|
&& upload_part_size_multiply_parts_count_threshold == other.upload_part_size_multiply_parts_count_threshold
|
|
|
|
&& max_single_part_upload_size == other.max_single_part_upload_size
|
2022-08-23 13:12:09 +00:00
|
|
|
&& max_connections == other.max_connections
|
|
|
|
&& check_objects_after_upload == other.check_objects_after_upload;
|
2022-04-06 20:27:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void updateFromSettingsIfEmpty(const Settings & settings);
|
2022-04-03 22:33:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
AuthSettings auth_settings;
|
|
|
|
ReadWriteSettings rw_settings;
|
2022-04-06 20:27:38 +00:00
|
|
|
|
|
|
|
inline bool operator==(const S3Settings & other) const
|
|
|
|
{
|
|
|
|
return auth_settings == other.auth_settings && rw_settings == other.rw_settings;
|
|
|
|
}
|
2020-06-01 17:16:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Settings for the StorageS3.
|
|
|
|
class StorageS3Settings
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
StorageS3Settings() = default;
|
2022-04-03 22:33:59 +00:00
|
|
|
void loadFromConfig(const String & config_elem, const Poco::Util::AbstractConfiguration & config, const Settings & settings);
|
2020-06-01 17:16:09 +00:00
|
|
|
|
2022-04-03 22:33:59 +00:00
|
|
|
S3Settings getSettings(const String & endpoint) const;
|
2020-06-01 17:16:09 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
mutable std::mutex mutex;
|
2022-04-03 22:33:59 +00:00
|
|
|
std::map<const String, const S3Settings> s3_settings;
|
2020-06-01 17:16:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|