From 172567f6ee168846b41d11ed7b8bd9c1ccbb659b Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 22 Aug 2021 13:58:49 +0100 Subject: Wait on specific events being processed --- lib/input/replStream.cpp | 2 ++ lib/input/replStream.h | 5 +++++ 2 files changed, 7 insertions(+) (limited to 'lib/input') 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(!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 +#include #include #include @@ -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; }; } -- cgit v1.2.3