![]() |
Dripline-Cpp
v2.4.2
Dripline Implementation in C++
|
A heartbeater repeatedly sends an alert on a particular time interval. More...
#include <heartbeater.hh>
Public Member Functions | |
heartbeater (service_ptr_t a_service=service_ptr_t()) | |
Primary constructor. A service pointer is required to be able to send messages. More... | |
heartbeater (const heartbeater &)=delete | |
heartbeater (heartbeater &&a_orig) | |
virtual | ~heartbeater () |
heartbeater & | operator= (const heartbeater &)=delete |
heartbeater & | operator= (heartbeater &&a_orig) |
void | execute (const std::string &a_name, uuid_t a_id, const std::string &a_routing_key) |
snake_case_mv_accessible (unsigned, heartbeat_interval_s) | |
Interval between heartbeat alerts (default: 60 s) More... | |
snake_case_mv_accessible (unsigned, check_timeout_ms) | |
Timing interval for the internal loop (default: 1000 ms) More... | |
snake_case_mv_referrable (service_ptr_t, service) | |
snake_case_mv_atomic (bool, stop) | |
Protected Attributes | |
std::thread | f_heartbeat_thread |
A heartbeater repeatedly sends an alert on a particular time interval.
This class is intended to be used as a mix-in to add heartbeat capabilities to another class by inheriting from it. See service as an example of its use.
The heartbeat is an alert sent to a pre-determined routing key, which is given as a parameter to the execute()
function. The interval for sending the heartbeats is f_heartbeat_interval_s
, which is in seconds. The default interval is 60 s.
If the heartbeat interval is 0, the sending of heartbeats is disabled.
The parameters provided upon execution are the name (a_name
, e.g. the service name), a UUID (a_id
), and the routing key (a_routing_key
).
The payload of each heartbeat message will be:
The routing key to which the message will be sent is a_routing_key.a_name
.
Definition at line 52 of file heartbeater.hh.
heartbeater | ( | service_ptr_t | a_service = service_ptr_t() | ) |
Primary constructor. A service pointer is required to be able to send messages.
Definition at line 25 of file heartbeater.cc.
|
delete |
heartbeater | ( | heartbeater && | a_orig | ) |
Definition at line 33 of file heartbeater.cc.
|
virtual |
Definition at line 41 of file heartbeater.cc.
void execute | ( | const std::string & | a_name, |
uuid_t | a_id, | ||
const std::string & | a_routing_key | ||
) |
Starts the heartbeat process. Heartbeat alerts are emitted every heartbeat_interval_s
seconds. If the interval is 0, then heartbeats are disabled.
a_name | The name for the heartbeater (e.g. the service) |
a_id | UUID for the heartbeater |
a_routing_key | The base of the routing key for heartbeat alerts; will be postpended with a_name |
Definition at line 53 of file heartbeater.cc.
|
delete |
heartbeater & operator= | ( | heartbeater && | a_orig | ) |
Definition at line 44 of file heartbeater.cc.
snake_case_mv_accessible | ( | unsigned | , |
heartbeat_interval_s | |||
) |
Interval between heartbeat alerts (default: 60 s)
snake_case_mv_accessible | ( | unsigned | , |
check_timeout_ms | |||
) |
Timing interval for the internal loop (default: 1000 ms)
snake_case_mv_atomic | ( | bool | , |
stop | |||
) |
snake_case_mv_referrable | ( | service_ptr_t | , |
service | |||
) |
|
protected |
Definition at line 83 of file heartbeater.hh.