seqeron 0.18.0
Loading...
Searching...
No Matches
Listeners.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <concepts>
4#include <cstddef>
5#include <cstdint>
6#include <string>
7
11
13
18template<typename L>
19concept ApplicationListener = requires(L& listener, const GroupDirectory& directory, const Payload& payload,
20 bool leading, std::int64_t clusterSeqNo, std::int64_t clusterTimeNs,
21 std::int64_t receiveTimeNs, ClusterError fence, const std::string& detail) {
22 // The gate crossed an edge. Every leadership change shuts an open gate, and the work may have gone with the
23 // election: Config::onNotLeader is where OutstandingWork::onNotLeader() belongs. False also comes before
24 // onFenced when this replica fences with its gate open.
25 listener.onLeadershipChanged(leading);
26 listener.onSequenced(payload);
27 listener.onFenced(fence, detail);
28};
29
34template<typename L>
36 requires(L& listener, const Payload& payload, ClusterError fence, const std::string& detail) {
37 // One application payload off the queue, in clusterSeqNo order.
38 listener.onSequenced(payload);
39 // Latched, once: this consumer may no longer be trusted to see the queue. Exiting is the usual way.
40 listener.onFenced(fence, detail);
41 };
42
48template<typename L>
50 requires(L& listener, const GroupDirectory& directory, const Payload& payload, std::int32_t connectionId,
51 const char* data, std::size_t length, std::int64_t clusterSeqNo, std::int64_t clusterTimeNs,
52 std::int64_t receiveTimeNs, ClusterError fence, const std::string& detail) {
53 // Open the edge; false is retried on the next doWork().
54 { listener.onActivated(connectionId) } -> std::convertible_to<bool>;
55 // Close it and drop every connection it let in: on a sibling's designation, and before onFenced when this
56 // instance fences while serving.
57 listener.onStandby();
58 listener.onSequenced(payload);
59 listener.onFenced(fence, detail);
60 };
61
62} // namespace org::limitless::seqeron::app
What an Application's Listener provides.
Definition Listeners.hpp:19
What a Consumer's Listener provides.
Definition Listeners.hpp:35
What a Gateway's Listener provides: the edge.
Definition Listeners.hpp:49
Definition ClusterError.hpp:5
ClusterError
Definition ClusterError.hpp:11