JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 1 | #pragma once |
2 | #include "logging.hpp" | ||||
3 | |||||
Ed Tanous | 601c71a | 2021-09-08 16:40:12 -0700 | [diff] [blame] | 4 | #include <boost/beast/http/fields.hpp> |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 5 | #include <boost/container/flat_map.hpp> |
Ed Tanous | a716aa7 | 2023-08-01 11:35:53 -0700 | [diff] [blame] | 6 | #include <boost/url/parse.hpp> |
Ed Tanous | 4a7fbef | 2024-04-06 16:03:49 -0700 | [diff] [blame] | 7 | #include <boost/url/url.hpp> |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 8 | #include <nlohmann/json.hpp> |
9 | |||||
10 | namespace persistent_data | ||||
11 | { | ||||
12 | |||||
13 | struct UserSubscription | ||||
14 | { | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 15 | // Represents a Redfish EventDestination instance |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 16 | std::string id; |
Ed Tanous | a716aa7 | 2023-08-01 11:35:53 -0700 | [diff] [blame] | 17 | boost::urls::url destinationUrl; |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 18 | std::string protocol; |
Ed Tanous | 19bb362 | 2024-07-05 10:07:40 -0500 | [diff] [blame] | 19 | bool verifyCertificate = true; |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 20 | std::string retryPolicy; |
21 | std::string customText; | ||||
22 | std::string eventFormatType; | ||||
23 | std::string subscriptionType; | ||||
24 | std::vector<std::string> registryMsgIds; | ||||
25 | std::vector<std::string> registryPrefixes; | ||||
26 | std::vector<std::string> resourceTypes; | ||||
Ed Tanous | 601c71a | 2021-09-08 16:40:12 -0700 | [diff] [blame] | 27 | boost::beast::http::fields httpHeaders; |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 28 | std::vector<std::string> metricReportDefinitions; |
Ed Tanous | a14c911 | 2024-09-04 10:46:47 -0700 | [diff] [blame] | 29 | std::vector<std::string> originResources; |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 30 | |
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 31 | static std::optional<UserSubscription> fromJson( |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 32 | const nlohmann::json::object_t& j, const bool loadFromOldConfig = false) |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 33 | { |
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 34 | UserSubscription subvalue; |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 35 | for (const auto& element : j) |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 36 | { |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 37 | if (element.first == "Id") |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 38 | { |
39 | const std::string* value = | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 40 | element.second.get_ptr<const std::string*>(); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 41 | if (value == nullptr) |
42 | { | ||||
43 | continue; | ||||
44 | } | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 45 | subvalue.id = *value; |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 46 | } |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 47 | else if (element.first == "Destination") |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 48 | { |
49 | const std::string* value = | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 50 | element.second.get_ptr<const std::string*>(); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 51 | if (value == nullptr) |
52 | { | ||||
53 | continue; | ||||
54 | } | ||||
Ed Tanous | 6fd2955 | 2023-10-04 09:40:14 -0700 | [diff] [blame] | 55 | boost::system::result<boost::urls::url> url = |
Ed Tanous | a716aa7 | 2023-08-01 11:35:53 -0700 | [diff] [blame] | 56 | boost::urls::parse_absolute_uri(*value); |
57 | if (!url) | ||||
58 | { | ||||
59 | continue; | ||||
60 | } | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 61 | subvalue.destinationUrl = std::move(*url); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 62 | } |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 63 | else if (element.first == "Protocol") |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 64 | { |
65 | const std::string* value = | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 66 | element.second.get_ptr<const std::string*>(); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 67 | if (value == nullptr) |
68 | { | ||||
69 | continue; | ||||
70 | } | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 71 | subvalue.protocol = *value; |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 72 | } |
Ed Tanous | 19bb362 | 2024-07-05 10:07:40 -0500 | [diff] [blame] | 73 | else if (element.first == "VerifyCertificate") |
74 | { | ||||
75 | const bool* value = element.second.get_ptr<const bool*>(); | ||||
76 | if (value == nullptr) | ||||
77 | { | ||||
78 | continue; | ||||
79 | } | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 80 | subvalue.verifyCertificate = *value; |
Ed Tanous | 19bb362 | 2024-07-05 10:07:40 -0500 | [diff] [blame] | 81 | } |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 82 | else if (element.first == "DeliveryRetryPolicy") |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 83 | { |
84 | const std::string* value = | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 85 | element.second.get_ptr<const std::string*>(); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 86 | if (value == nullptr) |
87 | { | ||||
88 | continue; | ||||
89 | } | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 90 | subvalue.retryPolicy = *value; |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 91 | } |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 92 | else if (element.first == "Context") |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 93 | { |
94 | const std::string* value = | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 95 | element.second.get_ptr<const std::string*>(); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 96 | if (value == nullptr) |
97 | { | ||||
98 | continue; | ||||
99 | } | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 100 | subvalue.customText = *value; |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 101 | } |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 102 | else if (element.first == "EventFormatType") |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 103 | { |
104 | const std::string* value = | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 105 | element.second.get_ptr<const std::string*>(); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 106 | if (value == nullptr) |
107 | { | ||||
108 | continue; | ||||
109 | } | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 110 | subvalue.eventFormatType = *value; |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 111 | } |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 112 | else if (element.first == "SubscriptionType") |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 113 | { |
114 | const std::string* value = | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 115 | element.second.get_ptr<const std::string*>(); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 116 | if (value == nullptr) |
117 | { | ||||
118 | continue; | ||||
119 | } | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 120 | subvalue.subscriptionType = *value; |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 121 | } |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 122 | else if (element.first == "MessageIds") |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 123 | { |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 124 | const nlohmann::json::array_t* obj = |
125 | element.second.get_ptr<const nlohmann::json::array_t*>(); | ||||
126 | if (obj == nullptr) | ||||
127 | { | ||||
128 | continue; | ||||
129 | } | ||||
130 | for (const auto& val : *obj) | ||||
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 131 | { |
132 | const std::string* value = | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 133 | val.get_ptr<const std::string*>(); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 134 | if (value == nullptr) |
135 | { | ||||
136 | continue; | ||||
137 | } | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 138 | subvalue.registryMsgIds.emplace_back(*value); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 139 | } |
140 | } | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 141 | else if (element.first == "RegistryPrefixes") |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 142 | { |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 143 | const nlohmann::json::array_t* obj = |
144 | element.second.get_ptr<const nlohmann::json::array_t*>(); | ||||
145 | if (obj == nullptr) | ||||
146 | { | ||||
147 | continue; | ||||
148 | } | ||||
149 | for (const auto& val : *obj) | ||||
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 150 | { |
151 | const std::string* value = | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 152 | val.get_ptr<const std::string*>(); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 153 | if (value == nullptr) |
154 | { | ||||
155 | continue; | ||||
156 | } | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 157 | subvalue.registryPrefixes.emplace_back(*value); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 158 | } |
159 | } | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 160 | else if (element.first == "ResourceTypes") |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 161 | { |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 162 | const nlohmann::json::array_t* obj = |
163 | element.second.get_ptr<const nlohmann::json::array_t*>(); | ||||
164 | if (obj == nullptr) | ||||
165 | { | ||||
166 | continue; | ||||
167 | } | ||||
168 | for (const auto& val : *obj) | ||||
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 169 | { |
170 | const std::string* value = | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 171 | val.get_ptr<const std::string*>(); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 172 | if (value == nullptr) |
173 | { | ||||
174 | continue; | ||||
175 | } | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 176 | subvalue.resourceTypes.emplace_back(*value); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 177 | } |
178 | } | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 179 | else if (element.first == "HttpHeaders") |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 180 | { |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 181 | const nlohmann::json::object_t* obj = |
182 | element.second.get_ptr<const nlohmann::json::object_t*>(); | ||||
183 | if (obj == nullptr) | ||||
184 | { | ||||
185 | continue; | ||||
186 | } | ||||
187 | for (const auto& val : *obj) | ||||
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 188 | { |
Ed Tanous | 601c71a | 2021-09-08 16:40:12 -0700 | [diff] [blame] | 189 | const std::string* value = |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 190 | val.second.get_ptr<const std::string*>(); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 191 | if (value == nullptr) |
192 | { | ||||
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 193 | BMCWEB_LOG_ERROR("Failed to parse value for key{}", |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 194 | val.first); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 195 | continue; |
196 | } | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 197 | subvalue.httpHeaders.set(val.first, *value); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 198 | } |
199 | } | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 200 | else if (element.first == "MetricReportDefinitions") |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 201 | { |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 202 | const nlohmann::json::array_t* obj = |
203 | element.second.get_ptr<const nlohmann::json::array_t*>(); | ||||
204 | if (obj == nullptr) | ||||
205 | { | ||||
206 | continue; | ||||
207 | } | ||||
208 | for (const auto& val : *obj) | ||||
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 209 | { |
210 | const std::string* value = | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 211 | val.get_ptr<const std::string*>(); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 212 | if (value == nullptr) |
213 | { | ||||
214 | continue; | ||||
215 | } | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 216 | subvalue.metricReportDefinitions.emplace_back(*value); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 217 | } |
218 | } | ||||
Ed Tanous | a14c911 | 2024-09-04 10:46:47 -0700 | [diff] [blame] | 219 | else if (element.first == "OriginResources") |
220 | { | ||||
221 | const nlohmann::json::array_t* obj = | ||||
222 | element.second.get_ptr<const nlohmann::json::array_t*>(); | ||||
223 | if (obj == nullptr) | ||||
224 | { | ||||
225 | continue; | ||||
226 | } | ||||
227 | for (const auto& val : *obj) | ||||
228 | { | ||||
229 | const std::string* value = | ||||
230 | val.get_ptr<const std::string*>(); | ||||
231 | if (value == nullptr) | ||||
232 | { | ||||
233 | continue; | ||||
234 | } | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 235 | subvalue.originResources.emplace_back(*value); |
Ed Tanous | a14c911 | 2024-09-04 10:46:47 -0700 | [diff] [blame] | 236 | } |
237 | } | ||||
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 238 | else |
239 | { | ||||
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 240 | BMCWEB_LOG_ERROR( |
241 | "Got unexpected property reading persistent file: {}", | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 242 | element.first); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 243 | continue; |
244 | } | ||||
245 | } | ||||
246 | |||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 247 | if ((subvalue.id.empty() && !loadFromOldConfig) || |
248 | subvalue.destinationUrl.empty() || subvalue.protocol.empty() || | ||||
249 | subvalue.retryPolicy.empty() || subvalue.eventFormatType.empty() || | ||||
250 | subvalue.subscriptionType.empty()) | ||||
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 251 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 252 | BMCWEB_LOG_ERROR("Subscription missing required field " |
253 | "information, refusing to restore"); | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 254 | return std::nullopt; |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 255 | } |
256 | |||||
257 | return subvalue; | ||||
258 | } | ||||
259 | }; | ||||
260 | |||||
261 | struct EventServiceConfig | ||||
262 | { | ||||
263 | bool enabled = true; | ||||
264 | uint32_t retryAttempts = 3; | ||||
265 | uint32_t retryTimeoutInterval = 30; | ||||
266 | |||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 267 | void fromJson(const nlohmann::json::object_t& j) |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 268 | { |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 269 | for (const auto& element : j) |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 270 | { |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 271 | if (element.first == "ServiceEnabled") |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 272 | { |
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 273 | const bool* value = element.second.get_ptr<const bool*>(); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 274 | if (value == nullptr) |
275 | { | ||||
276 | continue; | ||||
277 | } | ||||
278 | enabled = *value; | ||||
279 | } | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 280 | else if (element.first == "DeliveryRetryAttempts") |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 281 | { |
282 | const uint64_t* value = | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 283 | element.second.get_ptr<const uint64_t*>(); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 284 | if ((value == nullptr) || |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 285 | (*value > std::numeric_limits<uint32_t>::max())) |
286 | { | ||||
287 | continue; | ||||
288 | } | ||||
289 | retryAttempts = static_cast<uint32_t>(*value); | ||||
290 | } | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 291 | else if (element.first == "DeliveryRetryIntervalSeconds") |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 292 | { |
293 | const uint64_t* value = | ||||
Ed Tanous | 0bdda66 | 2023-08-03 17:27:34 -0700 | [diff] [blame] | 294 | element.second.get_ptr<const uint64_t*>(); |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 295 | if ((value == nullptr) || |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 296 | (*value > std::numeric_limits<uint32_t>::max())) |
297 | { | ||||
298 | continue; | ||||
299 | } | ||||
300 | retryTimeoutInterval = static_cast<uint32_t>(*value); | ||||
301 | } | ||||
302 | } | ||||
303 | } | ||||
304 | }; | ||||
305 | |||||
306 | class EventServiceStore | ||||
307 | { | ||||
308 | public: | ||||
Ed Tanous | 4b712a2 | 2023-08-02 12:56:52 -0700 | [diff] [blame^] | 309 | boost::container::flat_map<std::string, UserSubscription> |
JunLin Chen | 28afb49 | 2021-02-24 17:13:29 +0800 | [diff] [blame] | 310 | subscriptionsConfigMap; |
311 | EventServiceConfig eventServiceConfig; | ||||
312 | |||||
313 | static EventServiceStore& getInstance() | ||||
314 | { | ||||
315 | static EventServiceStore eventServiceStore; | ||||
316 | return eventServiceStore; | ||||
317 | } | ||||
318 | |||||
319 | EventServiceConfig& getEventServiceConfig() | ||||
320 | { | ||||
321 | return eventServiceConfig; | ||||
322 | } | ||||
323 | }; | ||||
324 | |||||
325 | } // namespace persistent_data |