mirror of
https://github.com/hoytech/strfry.git
synced 2025-06-18 17:27:11 +00:00
simplify quadrable instance creation
This commit is contained in:
2
golpe
2
golpe
Submodule golpe updated: c95388c461...e938a71c0d
@ -1,5 +1,4 @@
|
|||||||
appName: strfry
|
appName: strfry
|
||||||
quadrable: true
|
|
||||||
onAppStartup: true
|
onAppStartup: true
|
||||||
useGlobalH: true
|
useGlobalH: true
|
||||||
customLMDBSetup: true
|
customLMDBSetup: true
|
||||||
|
@ -42,11 +42,9 @@ void RelayServer::cleanupOldEvents() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (expiredLevIds.size() > 0) {
|
if (expiredLevIds.size() > 0) {
|
||||||
auto txn = env.txn_rw();
|
auto qdb = getQdbInstance();
|
||||||
|
|
||||||
quadrable::Quadrable qdb;
|
auto txn = env.txn_rw();
|
||||||
qdb.init(txn);
|
|
||||||
qdb.checkout("events");
|
|
||||||
|
|
||||||
uint64_t numDeleted = 0;
|
uint64_t numDeleted = 0;
|
||||||
auto changes = qdb.change();
|
auto changes = qdb.change();
|
||||||
@ -67,12 +65,7 @@ void RelayServer::cleanupOldEvents() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RelayServer::garbageCollect() {
|
void RelayServer::garbageCollect() {
|
||||||
quadrable::Quadrable qdb;
|
auto qdb = getQdbInstance();
|
||||||
{
|
|
||||||
auto txn = env.txn_ro();
|
|
||||||
qdb.init(txn);
|
|
||||||
}
|
|
||||||
qdb.checkout("events");
|
|
||||||
|
|
||||||
quadrableGarbageCollect(qdb, 1);
|
quadrableGarbageCollect(qdb, 1);
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,7 @@
|
|||||||
|
|
||||||
|
|
||||||
void RelayServer::runWriter(ThreadPool<MsgWriter>::Thread &thr) {
|
void RelayServer::runWriter(ThreadPool<MsgWriter>::Thread &thr) {
|
||||||
quadrable::Quadrable qdb;
|
auto qdb = getQdbInstance();
|
||||||
{
|
|
||||||
auto txn = env.txn_ro();
|
|
||||||
qdb.init(txn);
|
|
||||||
}
|
|
||||||
qdb.checkout("events");
|
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
auto newMsgs = thr.inbox.pop_all();
|
auto newMsgs = thr.inbox.pop_all();
|
||||||
|
@ -6,12 +6,7 @@
|
|||||||
|
|
||||||
|
|
||||||
void RelayServer::runYesstr(ThreadPool<MsgYesstr>::Thread &thr) {
|
void RelayServer::runYesstr(ThreadPool<MsgYesstr>::Thread &thr) {
|
||||||
quadrable::Quadrable qdb;
|
auto qdb = getQdbInstance();
|
||||||
{
|
|
||||||
auto txn = env.txn_ro();
|
|
||||||
qdb.init(txn);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct SyncState {
|
struct SyncState {
|
||||||
quadrable::MemStore m;
|
quadrable::MemStore m;
|
||||||
|
@ -58,12 +58,7 @@ struct WriterPipeline {
|
|||||||
writerThread = std::thread([&]() {
|
writerThread = std::thread([&]() {
|
||||||
setThreadName("Writer");
|
setThreadName("Writer");
|
||||||
|
|
||||||
quadrable::Quadrable qdb;
|
auto qdb = getQdbInstance();
|
||||||
{
|
|
||||||
auto txn = env.txn_ro();
|
|
||||||
qdb.init(txn);
|
|
||||||
}
|
|
||||||
qdb.checkout("events");
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
// Debounce
|
// Debounce
|
||||||
|
@ -32,12 +32,7 @@ void cmd_compact(const std::vector<std::string> &subArgs) {
|
|||||||
env.copy_fd(::fileno(f));
|
env.copy_fd(::fileno(f));
|
||||||
}
|
}
|
||||||
} else if (args["quad-gc"].asBool()) {
|
} else if (args["quad-gc"].asBool()) {
|
||||||
quadrable::Quadrable qdb;
|
auto qdb = getQdbInstance();
|
||||||
{
|
|
||||||
auto txn = env.txn_ro();
|
|
||||||
qdb.init(txn);
|
|
||||||
}
|
|
||||||
qdb.checkout("events");
|
|
||||||
|
|
||||||
quadrableGarbageCollect(qdb, 2);
|
quadrableGarbageCollect(qdb, 2);
|
||||||
}
|
}
|
||||||
|
@ -23,12 +23,7 @@ void cmd_import(const std::vector<std::string> &subArgs) {
|
|||||||
|
|
||||||
if (noVerify) LW << "not verifying event IDs or signatures!";
|
if (noVerify) LW << "not verifying event IDs or signatures!";
|
||||||
|
|
||||||
quadrable::Quadrable qdb;
|
auto qdb = getQdbInstance();
|
||||||
{
|
|
||||||
auto txn = env.txn_ro();
|
|
||||||
qdb.init(txn);
|
|
||||||
}
|
|
||||||
qdb.checkout("events");
|
|
||||||
|
|
||||||
auto txn = env.txn_rw();
|
auto txn = env.txn_rw();
|
||||||
|
|
||||||
|
@ -14,12 +14,7 @@ R"(
|
|||||||
void cmd_info(const std::vector<std::string> &subArgs) {
|
void cmd_info(const std::vector<std::string> &subArgs) {
|
||||||
std::map<std::string, docopt::value> args = docopt::docopt(USAGE, subArgs, true, "");
|
std::map<std::string, docopt::value> args = docopt::docopt(USAGE, subArgs, true, "");
|
||||||
|
|
||||||
quadrable::Quadrable qdb;
|
auto qdb = getQdbInstance();
|
||||||
{
|
|
||||||
auto txn = env.txn_ro();
|
|
||||||
qdb.init(txn);
|
|
||||||
}
|
|
||||||
qdb.checkout("events");
|
|
||||||
|
|
||||||
auto txn = env.txn_ro();
|
auto txn = env.txn_ro();
|
||||||
|
|
||||||
|
@ -133,20 +133,12 @@ void cmd_sync(const std::vector<std::string> &subArgs) {
|
|||||||
std::unique_ptr<SyncController> controller;
|
std::unique_ptr<SyncController> controller;
|
||||||
WriterPipeline writer;
|
WriterPipeline writer;
|
||||||
WSConnection ws(url);
|
WSConnection ws(url);
|
||||||
|
auto qdb = getQdbInstance();
|
||||||
quadrable::Quadrable qdb;
|
|
||||||
{
|
|
||||||
auto txn = env.txn_ro();
|
|
||||||
qdb.init(txn);
|
|
||||||
}
|
|
||||||
qdb.checkout("events");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ws.reconnect = false;
|
ws.reconnect = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (filterStr.size()) {
|
if (filterStr.size()) {
|
||||||
std::vector<uint64_t> levIds;
|
std::vector<uint64_t> levIds;
|
||||||
|
|
||||||
|
@ -4,3 +4,9 @@
|
|||||||
#include <parallel_hashmap/btree.h>
|
#include <parallel_hashmap/btree.h>
|
||||||
|
|
||||||
using namespace phmap;
|
using namespace phmap;
|
||||||
|
|
||||||
|
|
||||||
|
#include <quadrable.h>
|
||||||
|
|
||||||
|
quadrable::Quadrable getQdbInstance(lmdb::txn &txn);
|
||||||
|
quadrable::Quadrable getQdbInstance();
|
||||||
|
@ -67,7 +67,24 @@ static void setRLimits() {
|
|||||||
if (setrlimit(RLIMIT_NOFILE, &curr)) throw herr("Failed setting NOFILES limit to ", cfg().relay__nofiles, ": ", strerror(errno));
|
if (setrlimit(RLIMIT_NOFILE, &curr)) throw herr("Failed setting NOFILES limit to ", cfg().relay__nofiles, ": ", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
quadrable::Quadrable getQdbInstance(lmdb::txn &txn) {
|
||||||
|
quadrable::Quadrable qdb;
|
||||||
|
qdb.init(txn);
|
||||||
|
qdb.checkout("events");
|
||||||
|
return qdb;
|
||||||
|
}
|
||||||
|
|
||||||
|
quadrable::Quadrable getQdbInstance() {
|
||||||
|
auto txn = env.txn_ro();
|
||||||
|
return getQdbInstance(txn);
|
||||||
|
}
|
||||||
|
|
||||||
void onAppStartup(lmdb::txn &txn, const std::string &cmd) {
|
void onAppStartup(lmdb::txn &txn, const std::string &cmd) {
|
||||||
dbCheck(txn, cmd);
|
dbCheck(txn, cmd);
|
||||||
|
|
||||||
setRLimits();
|
setRLimits();
|
||||||
|
|
||||||
|
(void)getQdbInstance(txn);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user