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
@@ -232,6 +232,11 @@ if(_has_sqlite_async)
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE)
|
||||
endif()
|
||||
|
||||
has_modules(_has_storage Storage Core Functional Time Memory Binary IO Async)
|
||||
if(_has_storage)
|
||||
run_consumer(StorageOnly "${install_prefix}" "StorageOnly" ${_no_external_deps})
|
||||
endif()
|
||||
|
||||
# Foundation consumer with Core-formatting bridge and zero external packages.
|
||||
has_modules(_has_foundation Math Text Time Functional Binary FunctionalCoreFormatting Memory Core)
|
||||
if(_has_foundation)
|
||||
|
||||
@@ -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)
|
||||
@@ -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