-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e53133
commit b36bd95
Showing
10 changed files
with
217 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include "binsrv/s3_storage_backend.hpp" | ||
|
||
#include <cstddef> | ||
#include <filesystem> | ||
#include <memory> | ||
#include <string> | ||
#include <string_view> | ||
|
||
#include <aws/core/Aws.h> | ||
|
||
// TODO: remove this include when switching to clang-18 where transitive | ||
// IWYU 'export' pragmas are handled properly | ||
#include "binsrv/basic_storage_backend_fwd.hpp" | ||
|
||
#include "util/byte_span.hpp" | ||
#include "util/impl_helpers.hpp" | ||
|
||
namespace binsrv { | ||
|
||
using options_deimpl = util::deimpl<Aws::SDKOptions>; | ||
|
||
void s3_storage_backend::options_deleter::operator()(void *ptr) const noexcept { | ||
auto *casted_ptr{static_cast<Aws::SDKOptions *>(ptr)}; | ||
Aws::ShutdownAPI(*casted_ptr); | ||
// deleting via std::default_delete to avoid | ||
// cppcoreguidelines-owning-memory warnings | ||
using delete_helper = std::default_delete<Aws::SDKOptions>; | ||
delete_helper{}(casted_ptr); | ||
} | ||
|
||
s3_storage_backend::s3_storage_backend(std::string_view root_path) | ||
: root_path_{root_path}, options_{new Aws::SDKOptions} { | ||
Aws::InitAPI(*options_deimpl::get(options_)); | ||
} | ||
|
||
[[nodiscard]] storage_object_name_container | ||
s3_storage_backend::do_list_objects() { | ||
storage_object_name_container result; | ||
return result; | ||
} | ||
|
||
[[nodiscard]] std::string | ||
s3_storage_backend::do_get_object(std::string_view /*name*/) { | ||
static constexpr std::size_t file_size{8}; | ||
std::string file_content(file_size, 'x'); | ||
return file_content; | ||
} | ||
|
||
void s3_storage_backend::do_put_object(std::string_view /*name*/, | ||
util::const_byte_span /*content*/) {} | ||
|
||
void s3_storage_backend::do_open_stream(std::string_view /*name*/) {} | ||
|
||
void s3_storage_backend::do_write_data_to_stream( | ||
util::const_byte_span /*data*/) {} | ||
|
||
void s3_storage_backend::do_close_stream() {} | ||
|
||
[[nodiscard]] std::string s3_storage_backend::do_get_description() const { | ||
std::string res{"AWS S3 (SDK "}; | ||
const auto &casted_options = *options_deimpl::get(options_); | ||
res += std::to_string(casted_options.sdkVersion.major); | ||
res += '.'; | ||
res += std::to_string(casted_options.sdkVersion.minor); | ||
res += '.'; | ||
res += std::to_string(casted_options.sdkVersion.patch); | ||
res += ')'; | ||
return res; | ||
} | ||
} // namespace binsrv |
Oops, something went wrong.