mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-03 13:37:04 +00:00
The sink is also in charge of uploading large objects in parts, but this time each part is put with the help of upload-part-copy API call, not the regular upload-part one. To make it work the new sink inherits from the uploading base class, but instead of keeping memory_data_sink_buffers with parts it keeps a sink to upload a temporary intermediate object with parts. When the object is "full", i.e. the number of parts in it hits the limit, the object is flushed, then copied into the target object with the S3 API call, then deletes the intermediate object. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
80 lines
2.2 KiB
C++
80 lines
2.2 KiB
C++
/*
|
|
* Copyright (C) 2022-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#include <seastar/core/file.hh>
|
|
#include <seastar/core/sstring.hh>
|
|
#include <seastar/core/shared_ptr.hh>
|
|
#include <seastar/http/client.hh>
|
|
#include "utils/s3/creds.hh"
|
|
|
|
using namespace seastar;
|
|
class memory_data_sink_buffers;
|
|
|
|
namespace s3 {
|
|
|
|
struct range {
|
|
uint64_t off;
|
|
size_t len;
|
|
};
|
|
|
|
class client : public enable_shared_from_this<client> {
|
|
class upload_sink_base;
|
|
class upload_sink;
|
|
class upload_jumbo_sink;
|
|
class readable_file;
|
|
std::string _host;
|
|
endpoint_config_ptr _cfg;
|
|
http::experimental::client _http;
|
|
using global_factory = std::function<shared_ptr<client>(std::string)>;
|
|
global_factory _gf;
|
|
|
|
struct private_tag {};
|
|
|
|
void authorize(http::request&);
|
|
|
|
future<> get_object_header(sstring object_name, http::experimental::client::reply_handler handler);
|
|
public:
|
|
explicit client(std::string host, endpoint_config_ptr cfg, global_factory gf, private_tag);
|
|
static shared_ptr<client> make(std::string endpoint, endpoint_config_ptr cfg, global_factory gf = {});
|
|
|
|
future<uint64_t> get_object_size(sstring object_name);
|
|
struct stats {
|
|
uint64_t size;
|
|
std::time_t last_modified;
|
|
};
|
|
future<stats> get_object_stats(sstring object_name);
|
|
future<temporary_buffer<char>> get_object_contiguous(sstring object_name, std::optional<range> range = {});
|
|
future<> put_object(sstring object_name, temporary_buffer<char> buf);
|
|
future<> put_object(sstring object_name, ::memory_data_sink_buffers bufs);
|
|
future<> delete_object(sstring object_name);
|
|
|
|
file make_readable_file(sstring object_name);
|
|
data_sink make_upload_sink(sstring object_name);
|
|
data_sink make_upload_jumbo_sink(sstring object_name, std::optional<unsigned> max_parts_per_piece = {});
|
|
|
|
void update_config(endpoint_config_ptr);
|
|
|
|
struct handle {
|
|
std::string _host;
|
|
global_factory _gf;
|
|
public:
|
|
handle(const client& cln)
|
|
: _host(cln._host)
|
|
, _gf(cln._gf)
|
|
{}
|
|
|
|
shared_ptr<client> to_client() && {
|
|
return _gf(std::move(_host));
|
|
}
|
|
};
|
|
|
|
future<> close();
|
|
};
|
|
|
|
} // s3 namespace
|