NetworkedApplications: select the durable SQLite profile via storage_path
This commit is contained in:
1 parent
686f73ec9d
commit
e6aec57ad8
3 files changed
+79
-2
No files matched your search
@@ -1,5 +1,7 @@
|
||||
#include "networked_kv/application.hpp"
|
||||
|
||||
#include "networked_kv/sqlite_store.hpp"
|
||||
|
||||
#include <Void/Time/Clock.hpp>
|
||||
|
||||
#include <charconv>
|
||||
@@ -194,7 +196,15 @@ namespace NetworkedKv
|
||||
NetworkedApplication app;
|
||||
app.m_config = std::move(config);
|
||||
app.m_resources = resources;
|
||||
app.m_store = std::make_unique<MemoryKvStore>();
|
||||
if (app.m_config.storage_path.empty()) {
|
||||
app.m_store = std::make_unique<MemoryKvStore>();
|
||||
} else {
|
||||
auto durable = SqliteKvStore::open(app.m_config.storage_path);
|
||||
if (!durable) {
|
||||
return std::unexpected{std::move(durable).error()};
|
||||
}
|
||||
app.m_store = std::move(*durable);
|
||||
}
|
||||
app.m_api = std::make_unique<KvApi>(
|
||||
*app.m_store,
|
||||
ApiConfig{.bearer_token = app.m_config.bearer_token,
|
||||
|
||||
Reference in new issue
Block a user