summaryrefslogtreecommitdiff
path: root/lib/input
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-08-22 13:58:49 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2021-08-22 13:58:49 +0100
commit172567f6ee168846b41d11ed7b8bd9c1ccbb659b (patch)
tree31cb78c4dedc32e9629815b855ecc7bedfcaf0b0 /lib/input
parentAdd EventCounter class (diff)
downloadmygrate-172567f6ee168846b41d11ed7b8bd9c1ccbb659b.tar.bz2
mygrate-172567f6ee168846b41d11ed7b8bd9c1ccbb659b.tar.xz
mygrate-172567f6ee168846b41d11ed7b8bd9c1ccbb659b.zip
Wait on specific events being processed
Diffstat (limited to 'lib/input')
-rw-r--r--lib/input/replStream.cpp2
-rw-r--r--lib/input/replStream.h5
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/input/replStream.cpp b/lib/input/replStream.cpp
index d04e16b..3bfe877 100644
--- a/lib/input/replStream.cpp
+++ b/lib/input/replStream.cpp
@@ -39,8 +39,10 @@ namespace MyGrate::Input {
verify<MySQLErr>(!mariadb_rpl_open(rpl.get()), "Failed to mariadb_rpl_open", this);
while (MyGrate::MariaDB_Event_Ptr event {mariadb_rpl_fetch(rpl.get(), nullptr), &mariadb_free_rpl_event}) {
+ received.tick(event->event_type);
auto np = event->next_event_pos;
if (const auto & h = eventHandlers.at(event->event_type); h.func) {
+ handled.tick(event->event_type);
(eh.*h.func)(std::move(event));
}
position = np;
diff --git a/lib/input/replStream.h b/lib/input/replStream.h
index 40ec390..4958459 100644
--- a/lib/input/replStream.h
+++ b/lib/input/replStream.h
@@ -3,6 +3,7 @@
#include "mysqlConn.h"
#include <cstdint>
+#include <eventCounter.h>
#include <eventSourceBase.h>
#include <string>
@@ -19,10 +20,14 @@ namespace MyGrate::Input {
void readEvents(EventHandlerBase &) override;
void stopEvents() override;
+ const EventCounter & getReceivedCounts() const;
+ const EventCounter & getHandledCounts() const;
+
private:
uint64_t serverid;
std::string filename;
uint64_t position;
+ EventCounter received, handled;
};
}