-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstorage.hpp
More file actions
67 lines (55 loc) · 2.55 KB
/
Copy pathstorage.hpp
File metadata and controls
67 lines (55 loc) · 2.55 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
#pragma once
#include <string>
#include <chrono>
#include <memory>
#include "storageEngine.hpp"
#include "notify.hpp"
class Storage
{
public:
typedef std::function<void(std::string, int)> Logger;
typedef std::map < std::string, std::string > Strmap;
Storage():_initialized(false),_engine(nullptr), _logger(nullptr)
{
}
virtual ~Storage()
{
}
void setLogger(Logger func)
{
_logger = func;
}
void logger(std::string what, int verbosity);
void initialize(const nlohmann::json &settings, std::vector<std::shared_ptr< Notify>>& notifiers);
void close();
void addResponseTime(std::string& service, std::chrono::system_clock::time_point tm, uint64_t timeout);
/* output uuid or empty if error */
uint64_t addOutage(std::string& service, std::chrono::system_clock::time_point, std::string description);
void addBounce(uint64_t dbId, std::chrono::system_clock::time_point tm);
void solveOutage(uint64_t dbId, std::chrono::system_clock::time_point tm);
void setOutageError(uint64_t dbId, int val);
Strmap getOutageById(uint64_t outageId);
Strmap getOutageByUuid(std::string uuid);
void setOutageDescription(uint64_t outageId, std::string description);
void setOutageTags(uint64_t outageId, std::string tags);
std::list<Strmap> getHistoryOutages(std::chrono::system_clock::time_point from, std::chrono::system_clock::time_point to, const std::vector<std::string>& services, const std::map<std::string, std::string>& options);
std::list<Strmap> getServiceStats(std::chrono::system_clock::time_point from, std::chrono::system_clock::time_point to, const std::vector<std::string>& services, const std::map<std::string, std::string>& options);
std::map<std::string, std::list<Strmap>> getAllServiceStats(std::chrono::system_clock::time_point from, std::chrono::system_clock::time_point to, const uint64_t serviceId, const std::map<std::string, std::string>& options);
std::map<std::string, Strmap> getServicesDataByName(const std::vector<std::string>& services);
std::map<std::string, std::string> getServiceData(const uint64_t serviceId);
bool initialized()
{
return _initialized;
}
protected:
/* When and Outage is not flagged as solved or error. (Solved=0, or it's currently hapenning), but there are
more outages for the same service in database.
It happens when sermon hangs (or is killed) and the program starts again.
Old outages with this condition must be flagged as Probe_fail (-1) */
void fixOrphanOutages();
private:
bool _initialized;
std::shared_ptr<StorageEngine> _engine;
std::vector<std::shared_ptr< Notify>> notifiers;
Logger _logger;
};