BeeeOn Gateway
v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
|
Public Member Functions | |
FailDetector (const unsigned int failsTreshold=TRESHOLD_UNLIMITED) | |
void | fail () |
void | success () |
bool | isGoingToFail () const |
bool | isFailed () const |
Poco::Timestamp | timeOfLastFail () const |
bool | lastFailBefore (const Poco::Timespan &timeout) const |
Poco::Timestamp | timeOfFailure () const |
bool | failedBefore (const Poco::Timespan &timeout) const |
Static Public Attributes | |
static const int | TRESHOLD_UNLIMITED = 0 |
FailDetector::FailDetector | ( | const unsigned int | failsTreshold = TRESHOLD_UNLIMITED | ) |
The failsTreshold is number of fails needed to failure detection. Treshold = 0 means unlimited treshold.
void FailDetector::fail | ( | ) |
Increments count of fails and updates timeOfLastFail.
bool FailDetector::failedBefore | ( | const Poco::Timespan & | timeout | ) | const |
Returns true if the timeout has elapsed since failure (the moment when failsTreshold was reached).
Warning: If treshold was not reached yet, returns true if timeout is elapsed since creating FailDetector.
bool FailDetector::isFailed | ( | ) | const |
Returns true if counted of fails greater than or equal to fails treshold.
bool FailDetector::isGoingToFail | ( | ) | const |
Returns true if there is at least one fail detected already (even if the threshold has not been reached yet).
bool FailDetector::lastFailBefore | ( | const Poco::Timespan & | timeout | ) | const |
Returns true if the timeout has elapsed since last fail.
Warning: If fail() was not called yet, returns true if timeout is elapsed since creating FailDetector.
void FailDetector::success | ( | ) |
Resets the fails counter.
Timestamp FailDetector::timeOfFailure | ( | ) | const |
Returns Timestamp containing the time of failure (the moment when failsTreshold was reached).
Timestamp FailDetector::timeOfLastFail | ( | ) | const |
Returns Timestamp containing the time of last fail.