lintel 0.2.0
Loading...
Searching...
No Matches
HistoryService.h
Go to the documentation of this file.
7
8#include <ctime>
9#include <memory>
10
11#ifndef LINTEL_HISTORYSERVICE_H
12#define LINTEL_HISTORYSERVICE_H
13
14namespace lintel {
20 : public PropertyRegistration<HistoryService>
21 , public IHistoryService
22 , public std::enable_shared_from_this<HistoryService>
23{
24private:
25 // properties
26 std::shared_ptr<Property<std::chrono::seconds>> m_duration;
27 std::shared_ptr<Property<std::chrono::seconds>> m_period;
28 std::shared_ptr<Property<bool>> m_forceQueue;
29 std::shared_ptr<Property<std::size_t>> m_commitRate;
30 std::shared_ptr<Property<std::chrono::milliseconds>> m_sendTimeout;
31 // injections
32 std::shared_ptr<SchedulerService> m_schedulerService;
33 std::shared_ptr<HistoryRepository> m_historyRepository;
34 std::shared_ptr<MessageQueueService> m_messageQueueSerivice;
35 std::string m_ownProcessName;
36 std::shared_ptr<ProcessName> m_processName;
37 // variables
38 std::vector<HistoryEntry> m_historyEntries;
39 std::mutex m_historyEntriesMutex;
40 std::atomic_bool m_running = true;
41 std::unique_ptr<MessageQueue<Message>> m_historyMessageQueue;
42 std::unique_ptr<MessageQueue<Message>> m_historyMessageQueueReceive;
43
45 void run();
46
48 struct HistoryMessage
49 {
50 char processName[100];
51 char serviceName[100];
52 char label[100];
53 char text[300];
54 std::time_t createdTimestamp;
55 int64_t createdTimestampMics;
56 };
57
58public:
66 HistoryService(std::shared_ptr<ProcessName> processName,
67 std::shared_ptr<SchedulerService> schedulerService,
68 std::shared_ptr<HistoryRepository> historyRepository,
69 std::shared_ptr<MessageQueueService> messageQueueService);
70
71 ~HistoryService() override;
72
73 void onInitialize() override;
74
75 void onShutdown() override;
76
81 void historizeOf(std::vector<HistoryEntry> entries) override;
82
84 [[nodiscard]] const std::string &getProcessName() const override;
85
87 [[nodiscard]] std::vector<HistoryEntry> allOf() const override;
88
93 [[nodiscard]] std::vector<HistoryEntry> allOf(const std::string &label) const override;
94
100 [[nodiscard]] std::vector<HistoryEntry> allOf(const std::string &processName,
101 const std::string &serviceName) const override;
102
107 [[nodiscard]] std::vector<HistoryEntry> allOfProcess(const std::string &processName) const override;
108
113 [[nodiscard]] std::vector<HistoryEntry> allOfService(const std::string &serviceName) const override;
114};
115
116}// namespace lintel
117#endif// LINTEL_HISTORYSERVICE_H
Definition HistoryService.h:23
std::vector< HistoryEntry > allOf(const std::string &label) const override
std::vector< HistoryEntry > allOf() const override
std::vector< HistoryEntry > allOf(const std::string &processName, const std::string &serviceName) const override
HistoryService(std::shared_ptr< ProcessName > processName, std::shared_ptr< SchedulerService > schedulerService, std::shared_ptr< HistoryRepository > historyRepository, std::shared_ptr< MessageQueueService > messageQueueService)
std::vector< HistoryEntry > allOfService(const std::string &serviceName) const override
const std::string & getProcessName() const override
void historizeOf(std::vector< HistoryEntry > entries) override
std::vector< HistoryEntry > allOfProcess(const std::string &processName) const override
void onShutdown() override
~HistoryService() override
void onInitialize() override
Definition IHistoryService.h:19
Definition PropertyRegistration.h:14
Definition BaseFeature.h:6
constexpr std::string_view type_name()
Definition TypeName.h:9