Repo-Init
 
Loading...
Searching...
No Matches
ZeroMQMonitor.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <zmq.hpp>
4
5#include <atomic>
6#include <string>
7#include <thread>
8
17class ZeroMQMonitor : private zmq::monitor_t {
18 private:
19 std::unique_ptr<std::thread> _monitorThread;
20 std::atomic_flag _shouldStop{false};
22 void threadFunc();
23
24 static void on_event(const std::string &messageStr, int level, const char *addr = nullptr);
25
26 void on_monitor_started() override;
27
28 void on_event_connected(const zmq_event_t & /*unused*/, const char *addr_) override;
29
30 void on_event_connect_delayed(const zmq_event_t & /*unused*/, const char *addr_) override;
31
32 void on_event_connect_retried(const zmq_event_t & /*unused*/, const char *addr_) override;
33
34 void on_event_listening(const zmq_event_t & /*unused*/, const char *addr_) override;
35
36 void on_event_bind_failed(const zmq_event_t & /*unused*/, const char *addr_) override;
37
38 void on_event_accepted(const zmq_event_t & /*unused*/, const char *addr_) override;
39
40 void on_event_accept_failed(const zmq_event_t & /*unused*/, const char *addr_) override;
41
42 void on_event_closed(const zmq_event_t & /*unused*/, const char *addr_) override;
43
44 void on_event_close_failed(const zmq_event_t & /*unused*/, const char *addr_) override;
45
46 void on_event_disconnected(const zmq_event_t & /*unused*/, const char *addr_) override;
47
48#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 3, 0) || \
49 (defined(ZMQ_BUILD_DRAFT_API) && ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 2, 3))
50 void on_event_handshake_failed_no_detail(const zmq_event_t & /*unused*/, const char *addr_) override;
51
52 void on_event_handshake_failed_protocol(const zmq_event_t & /*unused*/, const char *addr_) override;
53
54 void on_event_handshake_failed_auth(const zmq_event_t & /*unused*/, const char *addr_) override;
55
56 void on_event_handshake_succeeded(const zmq_event_t & /*unused*/, const char *addr_) override;
57
58#elif defined(ZMQ_BUILD_DRAFT_API) && ZMQ_VERSION >= ZMQ_MAKE_VERSION(4, 2, 1)
59 void on_event_handshake_failed(const zmq_event_t & /*unused*/, const char *addr_) override;
60
61 void on_event_handshake_succeed(const zmq_event_t & /*unused*/, const char *addr_) override;
62#endif
63
64 void on_event_unknown(const zmq_event_t & /*unused*/, const char *addr_) override;
65
66 public:
68 ZeroMQMonitor() = default;
69
71 ZeroMQMonitor(const ZeroMQMonitor & /*unused*/) = delete;
72
74 ZeroMQMonitor(ZeroMQMonitor && /*unused*/) = delete;
75
77 ZeroMQMonitor &operator=(ZeroMQMonitor /*unused*/) = delete;
78
80 ZeroMQMonitor &operator=(ZeroMQMonitor && /*unused*/) = delete;
81
91 void startMonitoring(zmq::socket_t *socket, const std::string &monitorAddress);
92
96 void stopMonitoring();
97
102};
void on_event_unknown(const zmq_event_t &, const char *addr_) override
void on_event_connect_retried(const zmq_event_t &, const char *addr_) override
ZeroMQMonitor()=default
Constructor.
ZeroMQMonitor & operator=(ZeroMQMonitor &&)=delete
Move assignment operator.
void on_event_disconnected(const zmq_event_t &, const char *addr_) override
void on_event_bind_failed(const zmq_event_t &, const char *addr_) override
void on_event_connect_delayed(const zmq_event_t &, const char *addr_) override
void on_event_listening(const zmq_event_t &, const char *addr_) override
void on_event_closed(const zmq_event_t &, const char *addr_) override
void startMonitoring(zmq::socket_t *socket, const std::string &monitorAddress)
void on_event_connected(const zmq_event_t &, const char *addr_) override
void on_event_handshake_succeeded(const zmq_event_t &, const char *addr_) override
void on_event_accepted(const zmq_event_t &, const char *addr_) override
std::unique_ptr< std::thread > _monitorThread
void on_event_handshake_failed_auth(const zmq_event_t &, const char *addr_) override
ZeroMQMonitor(const ZeroMQMonitor &)=delete
Copy constructor.
void on_event_accept_failed(const zmq_event_t &, const char *addr_) override
static void on_event(const std::string &messageStr, int level, const char *addr=nullptr)
void on_monitor_started() override
void on_event_handshake_failed_no_detail(const zmq_event_t &, const char *addr_) override
void on_event_handshake_failed_protocol(const zmq_event_t &, const char *addr_) override
~ZeroMQMonitor() override
std::atomic_flag _shouldStop
ZeroMQMonitor & operator=(ZeroMQMonitor)=delete
Copy assignment operator.
void on_event_close_failed(const zmq_event_t &, const char *addr_) override
ZeroMQMonitor(ZeroMQMonitor &&)=delete
Move constructor.