Skip to content

Commit e6198f6

Browse files
committed
Compiling
1 parent 23ef7a6 commit e6198f6

File tree

4 files changed

+41
-19
lines changed

4 files changed

+41
-19
lines changed

cpp/arcticdb/storage/mock/s3_mock_client.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ S3Result<Segment> MockS3Client::get_object(
8080
return {pos->second.clone()};
8181
}
8282

83+
folly::Future<S3Result<Segment>> MockS3Client::get_object_async(
84+
const std::string &s3_object_name,
85+
const std::string &bucket_name) const {
86+
return folly::makeFuture(get_object(s3_object_name, bucket_name));
87+
}
88+
8389
S3Result<std::monostate> MockS3Client::put_object(
8490
const std::string &s3_object_name,
8591
Segment &&segment,

cpp/arcticdb/storage/mock/s3_mock_client.hpp

+23-15
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct S3Key {
4040
// The MockS3Client can simulate storage failures by using the get_failure_trigger for s3_object_names.
4141
class MockS3Client : public S3ClientInterface {
4242
public:
43-
MockS3Client(){}
43+
MockS3Client() {}
4444

4545
// Can be used to trigger a simulated failure inside MockS3Client. For example:
4646
// auto object_to_trigger_put_failure = get_failure_trigger("test", StorageOperation::WRITE, Aws::S3::S3Errors::NETWORK_FAILURE, false);
@@ -49,28 +49,36 @@ class MockS3Client : public S3ClientInterface {
4949
// The returned name looks like "{s3_object_name}#Failure_{operation_to_fail}_{error_to_fail_with}_{retryable}".
5050
// For example: "symbol_1#Failure_Delete_99_1" will trigger a delete failure with code 99 which is retryable.
5151
static std::string get_failure_trigger(
52-
const std::string& s3_object_name,
53-
StorageOperation operation_to_fail,
54-
Aws::S3::S3Errors error_to_fail_with,
55-
bool retryable=true);
52+
const std::string& s3_object_name,
53+
StorageOperation operation_to_fail,
54+
Aws::S3::S3Errors error_to_fail_with,
55+
bool retryable = true);
5656

57-
[[nodiscard]] S3Result<std::monostate> head_object(const std::string& s3_object_name, const std::string& bucket_name) const override;
57+
[[nodiscard]] S3Result<std::monostate> head_object(
58+
const std::string& s3_object_name,
59+
const std::string& bucket_name) const override;
5860

59-
[[nodiscard]] S3Result<Segment> get_object(const std::string& s3_object_name, const std::string& bucket_name) const override;
61+
[[nodiscard]] S3Result<Segment> get_object(
62+
const std::string& s3_object_name,
63+
const std::string& bucket_name) const override;
64+
65+
[[nodiscard]] folly::Future<S3Result<Segment>> get_object_async(
66+
const std::string& s3_object_name,
67+
const std::string& bucket_name) const override;
6068

6169
S3Result<std::monostate> put_object(
62-
const std::string& s3_object_name,
63-
Segment&& segment,
64-
const std::string& bucket_name) override;
70+
const std::string& s3_object_name,
71+
Segment&& segment,
72+
const std::string& bucket_name) override;
6573

6674
S3Result<DeleteOutput> delete_objects(
67-
const std::vector<std::string>& s3_object_names,
68-
const std::string& bucket_name) override;
75+
const std::vector<std::string>& s3_object_names,
76+
const std::string& bucket_name) override;
6977

7078
S3Result<ListObjectsOutput> list_objects(
71-
const std::string& prefix,
72-
const std::string& bucket_name,
73-
const std::optional<std::string>& continuation_token) const override;
79+
const std::string& prefix,
80+
const std::string& bucket_name,
81+
const std::optional<std::string>& continuation_token) const override;
7482

7583
private:
7684
std::map<S3Key, Segment> s3_contents;

cpp/arcticdb/storage/s3/detail-inl.hpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static const size_t DELETE_OBJECTS_LIMIT = 1000;
4545
template<class It>
4646
using Range = folly::Range<It>;
4747

48-
inline void raise_s3_exception(const Aws::S3::S3Error& err, const std::string& object_name) {
48+
[[noreturn]] inline void raise_s3_exception(const Aws::S3::S3Error& err, const std::string& object_name) {
4949
std::string error_message;
5050
auto type = err.GetErrorType();
5151

@@ -190,10 +190,15 @@ folly::Future<KeySegmentPair> do_async_read_impl(
190190
const std::string& bucket_name,
191191
const S3ClientInterface& s3_client,
192192
KeyBucketizer&& bucketizer,
193-
ReadKeyOpts opts) {
193+
ReadKeyOpts) {
194194
auto key_type_dir = key_type_folder(root_folder, variant_key_type(variant_key));
195195
auto s3_object_name = object_path(bucketizer.bucketize(key_type_dir, variant_key), variant_key);
196-
return s3_client.get_object_async(bucket_name, s3_object_name);
196+
return s3_client.get_object_async(bucket_name, s3_object_name).thenValue([vk=std::move(variant_key)] (auto&& result) mutable -> KeySegmentPair {
197+
if(result.is_success())
198+
return KeySegmentPair(std::move(vk), std::move(result.get_output()));
199+
else
200+
raise_s3_exception(result.get_error(), fmt::format("{}", vk));
201+
});
197202
}
198203

199204
template<class KeyBucketizer>

cpp/arcticdb/storage/s3/s3_storage.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ KeySegmentPair S3Storage::do_read(VariantKey&& variant_key, ReadKeyOpts opts) {
5959
}
6060

6161
folly::Future<folly::Unit> S3Storage::do_async_read(entity::VariantKey&& variant_key, const ReadVisitor& visitor, ReadKeyOpts opts) {
62-
62+
return detail::do_async_read_impl(std::move(variant_key), root_folder_, bucket_name_, *s3_client_, FlatBucketizer{}, opts).thenValue([&visitor] (auto&& key_seg) {
63+
visitor(key_seg.variant_key(), std::move(key_seg.segment()));
64+
return folly::Unit{};
65+
});
6366
}
6467

6568
folly::Future<KeySegmentPair> S3Storage::do_async_read(entity::VariantKey&& variant_key, ReadKeyOpts opts) {

0 commit comments

Comments
 (0)