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