Implement Report persistency
Now Report properties are stored in non-volatile memory. It allows
to restore Report after system restart. Persistency of a report is
controlled by Persistency property in Report interface.
Tested:
- Passed unit tests
- Verified that report is stored in /var/lib/telemetry dir
- Verified that report is restored from storage after telemetry
service start
Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
Change-Id: Iccfe21603eecffc4e174a4403f699b03de320db9
diff --git a/src/report_manager.hpp b/src/report_manager.hpp
index 2427b76..a26b59e 100644
--- a/src/report_manager.hpp
+++ b/src/report_manager.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include "interfaces/json_storage.hpp"
#include "interfaces/report.hpp"
#include "interfaces/report_factory.hpp"
#include "interfaces/report_manager.hpp"
@@ -15,6 +16,7 @@
public:
ReportManager(
std::unique_ptr<interfaces::ReportFactory> reportFactory,
+ std::unique_ptr<interfaces::JsonStorage> reportStorage,
const std::shared_ptr<sdbusplus::asio::object_server>& objServer);
~ReportManager() = default;
@@ -28,10 +30,19 @@
private:
std::unique_ptr<interfaces::ReportFactory> reportFactory;
+ std::unique_ptr<interfaces::JsonStorage> reportStorage;
std::shared_ptr<sdbusplus::asio::object_server> objServer;
std::unique_ptr<sdbusplus::asio::dbus_interface> reportManagerIface;
std::vector<std::unique_ptr<interfaces::Report>> reports;
+ std::unique_ptr<interfaces::Report>& addReport(
+ std::optional<std::reference_wrapper<boost::asio::yield_context>> yield,
+ const std::string& reportName, const std::string& reportingType,
+ const bool emitsReadingsUpdate, const bool logToMetricReportsCollection,
+ std::chrono::milliseconds interval,
+ const ReadingParameters& metricParams);
+ void loadFromPersistent();
+
public:
static constexpr uint32_t maxReports{20};
static constexpr std::chrono::milliseconds minInterval{1000};