feat(sqlite): harden Sqlite lifecycle/transactions/migrations/ops and add SqliteAsync pool
This commit is contained in:
1 parent
9925ea1764
commit
427cc9a843
15 files changed
+4438
-134
No files matched your search
@@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidSqliteAsyncOnlyConsumer LANGUAGES CXX)
|
||||
|
||||
find_package(Void CONFIG REQUIRED COMPONENTS SqliteAsync)
|
||||
|
||||
add_executable(void_sqlite_async_only_consumer main.cpp)
|
||||
target_link_libraries(void_sqlite_async_only_consumer PRIVATE Void::SqliteAsync)
|
||||
target_compile_features(void_sqlite_async_only_consumer PRIVATE cxx_std_26)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME SqliteAsyncOnlyConsumer COMMAND void_sqlite_async_only_consumer)
|
||||
@@ -0,0 +1,24 @@
|
||||
#include <Void/Sqlite/AsyncPool.hpp>
|
||||
|
||||
#include <atomic>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
const auto dir = std::filesystem::temp_directory_path() /
|
||||
("void-sqlite-async-pkg-" + std::to_string(::getpid()));
|
||||
std::error_code ec;
|
||||
std::filesystem::remove_all(dir, ec);
|
||||
std::filesystem::create_directories(dir, ec);
|
||||
|
||||
Void::Sqlite::AsyncPoolOptions opts;
|
||||
opts.path = dir / "pkg.db";
|
||||
opts.reader_connections = 2;
|
||||
auto pool = Void::Sqlite::AsyncPool::open(opts);
|
||||
const bool ok = pool.has_value() && pool->stats().reader_connections == 2 &&
|
||||
pool->close_and_join().has_value();
|
||||
std::filesystem::remove_all(dir, ec);
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
Reference in new issue
Block a user