feat(storage): implement original V1 durable Storage engine, tools, and async adapter

This commit is contained in:
faumaray committed 2026-11-26 15:32:43 +03:00
1 parent 427cc9a843
commit fdf0da5ca8
21 files changed
+6966

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 4.0)
project(VoidStorageOnlyConsumer LANGUAGES CXX)
find_package(Void CONFIG REQUIRED COMPONENTS Storage)
add_executable(void_storage_only_consumer main.cpp)
target_link_libraries(void_storage_only_consumer PRIVATE Void::Storage)
target_compile_features(void_storage_only_consumer PRIVATE cxx_std_26)
enable_testing()
add_test(NAME StorageOnlyConsumer COMMAND void_storage_only_consumer)
+36
View File
@@ -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;
}