17 #ifndef __COMMON_HEARTBEATER_HPP__ 18 #define __COMMON_HEARTBEATER_HPP__ 40 template<
typename Message,
typename Event>
46 const std::string& _logMessage,
47 const Message& _heartbeatMessage,
51 const Option<lambda::function<
void()>>& _callback =
None())
53 logMessage(_logMessage),
54 heartbeatMessage(_heartbeatMessage),
55 connection(_connection),
58 callback(_callback) {}
67 &ResponseHeartbeaterProcess::heartbeat);
77 if (connection.closed().isPending()) {
78 VLOG(2) <<
"Sending heartbeat to " << logMessage;
84 connection.send(heartbeatMessage);
87 process::delay(interval,
this, &ResponseHeartbeaterProcess::heartbeat);
90 const std::string logMessage;
91 const Message heartbeatMessage;
99 template<
typename Message,
typename Event>
104 const std::string& _logMessage,
105 const Message& _heartbeatMessage,
109 const Option<lambda::function<
void()>>& _callback =
None())
138 #endif // __COMMON_HEARTBEATER_HPP__ std::string generate(const std::string &prefix="")
Returns 'prefix(N)' where N represents the number of instances where the same prefix (wrt...
ProcessBase(const std::string &id="")
ResponseHeartbeater(const std::string &_logMessage, const Message &_heartbeatMessage, const StreamingHttpConnection< Event > &_connection, const Duration &_interval, const Option< Duration > &_delay=None(), const Option< lambda::function< void()>> &_callback=None())
Definition: heartbeater.hpp:103
ResponseHeartbeaterProcess(const std::string &_logMessage, const Message &_heartbeatMessage, const StreamingHttpConnection< Event > &_connection, const Duration &_interval, const Option< Duration > &_delay=None(), const Option< lambda::function< void()>> &_callback=None())
Definition: heartbeater.hpp:45
Definition: heartbeater.hpp:41
UPID spawn(ProcessBase *process, bool manage=false)
Spawn a new process.
Definition: duration.hpp:32
void terminate(const UPID &pid, bool inject=true)
Sends a TerminateEvent to the given process.
bool isSome() const
Definition: option.hpp:116
mesos::v1::scheduler::Event Event
Definition: mesos.hpp:2852
~ResponseHeartbeater()
Definition: heartbeater.hpp:121
Timer delay(const Duration &duration, const PID< T > &pid, void(T::*method)())
Definition: delay.hpp:31
const T & get() const &
Definition: option.hpp:119
bool wait(const UPID &pid, const Duration &duration=Seconds(-1))
Wait for the process to exit for no more than the specified seconds.
Definition: heartbeater.hpp:100
Result< Process > process(pid_t pid)
Definition: freebsd.hpp:30
Definition: attributes.hpp:24
Definition: executor.hpp:48
void initialize() override
Invoked when a process gets spawned.
Definition: heartbeater.hpp:61
Definition: process.hpp:505