feat(storage): implement original V1 durable Storage engine, tools, and async adapter
This commit is contained in:
1 parent
427cc9a843
commit
fdf0da5ca8
21 files changed
+6966
No files matched your search
@@ -0,0 +1,36 @@
|
||||
#include <Void/Storage/Storage.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
if (Void::Storage::crc32c(std::string_view{"123456789"}) != 0xE3069283u) {
|
||||
return 1;
|
||||
}
|
||||
const auto dir = std::filesystem::temp_directory_path() /
|
||||
("void-storage-pkg-" + std::to_string(::getpid()));
|
||||
std::error_code ec;
|
||||
std::filesystem::remove_all(dir, ec);
|
||||
|
||||
Void::Storage::OpenOptions opts;
|
||||
opts.directory = dir;
|
||||
auto eng = Void::Storage::Engine::open(opts);
|
||||
if (!eng) return 2;
|
||||
|
||||
Void::Storage::Batch b;
|
||||
b.require_absent("hello").put("hello", "world");
|
||||
auto wr = eng->write(std::move(b), Void::Storage::Durability::Sync);
|
||||
if (!wr) return 3;
|
||||
|
||||
auto snap = eng->snapshot();
|
||||
if (!snap) return 4;
|
||||
auto val = eng->get(*snap, "hello");
|
||||
const bool ok = val && val->as_string_view() == "world" && val->version == wr->sequence;
|
||||
snap->reset();
|
||||
const bool closed = eng->close().has_value();
|
||||
|
||||
std::filesystem::remove_all(dir, ec);
|
||||
return (ok && closed) ? 0 : 5;
|
||||
}
|
||||
Reference in new issue
Block a user