-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathservice_fail.cpp
More file actions
85 lines (73 loc) · 1.94 KB
/
Copy pathservice_fail.cpp
File metadata and controls
85 lines (73 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
*************************************************************
* @file service_fail.cpp
* @brief Breve descripción
* Pequeña documentación del archivo
*
*
*
*
*
* @author Gaspar Fernández <blakeyed@totaki.com>
* @version
* @date 14 dic 2015
* Historial de cambios:
*
*
*************************************************************/
#include "service_fail.hpp"
ServiceFail::ServiceFail(const std::string &serviceName, uint64_t dbId, std :: vector < std::shared_ptr<Notify>> & notifiers, int errorCode, const std::string &message):
serviceName(serviceName), errorCode(errorCode), lastMessage(message), notifiers(notifiers), dbId(dbId), bounces(0)
{
outageStart = std::chrono::system_clock::now();
for (auto n : notifiers)
n->newFail(serviceName, outageStart, errorCode, message);
}
ServiceFail::ServiceFail(const ServiceFail & sf): notifiers(sf.notifiers),
serviceName(sf.serviceName),
outageStart(sf.outageStart),
errorCode(sf.errorCode),
bounces(sf.bounces),
dbId(sf.dbId),
lastMessage(sf.lastMessage)
{
}
ServiceFail::ServiceFail(ServiceFail && sf) : notifiers(std::move(sf.notifiers)),
serviceName(std::move(sf.serviceName)),
outageStart(std::move(sf.outageStart)),
errorCode(std::move(sf.errorCode)),
dbId(sf.dbId),
bounces(sf.bounces),
lastMessage(std::move(sf.lastMessage))
{
}
ServiceFail::~ServiceFail()
{
}
void ServiceFail::bounce()
{
bounces++;
for (auto n : notifiers)
n->newBounce(serviceName, bounces, outageStart, std::chrono::system_clock::now(), errorCode, lastMessage);
}
uint64_t ServiceFail::getBounces()
{
return bounces;
}
std::chrono::system_clock::time_point ServiceFail::getStartTime()
{
return outageStart;
}
std::string ServiceFail::getServiceName()
{
return serviceName;
}
std::string ServiceFail::getLastMessage()
{
return lastMessage;
}
void ServiceFail::end()
{
for (auto n : notifiers)
n->newRecovery(serviceName, outageStart, std::chrono::system_clock::now(), errorCode, lastMessage);
}