Files
scylladb/utils/s3/client.hh
Pavel Emelyanov 033fa107f8 utils: Add S3 readable file impl for random reads
Sometimes an sstable is used for random read, sometimes -- for streamed
read using the input stream. For both cases the file API can be
provided, because S3 API allows random reads of arbitrary lengths.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2023-04-10 16:43:01 +03:00

50 lines
1.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>
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;
class readable_file;
socket_address _addr;
sstring _host;
http::experimental::client _http;
struct private_tag {};
public:
explicit client(socket_address addr, private_tag);
static shared_ptr<client> make(socket_address addr);
future<uint64_t> get_object_size(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);
future<> close();
};
} // s3 namespace