Commit 46274a2
authored
refactor: Improve EventExecutor (#393)
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->
## This PR
<!-- add the description of the PR here -->
This pull request to `src/OpenFeature/EventExecutor.cs` includes changes
to improve code readability and performance. The most important changes
include replacing `List` and `Dictionary` initializations with shorthand
syntax, switching from `Thread` to `Task` for asynchronous operations,
and refactoring methods for better clarity and maintainability.
Improvements to code readability and performance:
*
[`src/OpenFeature/EventExecutor.cs`](diffhunk://#diff-f563baadcf750bb66efaea76d7ec4783320e6efdc45c468effb531c948a2292cL13-R28):
Replaced `List` and `Dictionary` initializations with shorthand syntax
`[]`.
[[1]](diffhunk://#diff-f563baadcf750bb66efaea76d7ec4783320e6efdc45c468effb531c948a2292cL13-R28)
[[2]](diffhunk://#diff-f563baadcf750bb66efaea76d7ec4783320e6efdc45c468effb531c948a2292cL45-R41)
[[3]](diffhunk://#diff-f563baadcf750bb66efaea76d7ec4783320e6efdc45c468effb531c948a2292cL73-R75)
*
[`src/OpenFeature/EventExecutor.cs`](diffhunk://#diff-f563baadcf750bb66efaea76d7ec4783320e6efdc45c468effb531c948a2292cL149-R144):
Changed from using `Thread` to `Task` for asynchronous operations to
improve performance and simplify the code.
[[1]](diffhunk://#diff-f563baadcf750bb66efaea76d7ec4783320e6efdc45c468effb531c948a2292cL149-R144)
[[2]](diffhunk://#diff-f563baadcf750bb66efaea76d7ec4783320e6efdc45c468effb531c948a2292cL219-R213)
[[3]](diffhunk://#diff-f563baadcf750bb66efaea76d7ec4783320e6efdc45c468effb531c948a2292cL237-R257)
Refactoring for better clarity and maintainability:
*
[`src/OpenFeature/EventExecutor.cs`](diffhunk://#diff-f563baadcf750bb66efaea76d7ec4783320e6efdc45c468effb531c948a2292cL189-L204):
Refactored `EmitOnRegistration` method to use a switch expression for
setting the message based on provider status and event type, improving
readability.
*
[`src/OpenFeature/EventExecutor.cs`](diffhunk://#diff-f563baadcf750bb66efaea76d7ec4783320e6efdc45c468effb531c948a2292cR266-R275):
Split `ProcessEventAsync` method into smaller methods
(`ProcessApiHandlers`, `ProcessClientHandlers`,
`ProcessDefaultProviderHandlers`) for better organization and
maintainability.
[[1]](diffhunk://#diff-f563baadcf750bb66efaea76d7ec4783320e6efdc45c468effb531c948a2292cR266-R275)
[[2]](diffhunk://#diff-f563baadcf750bb66efaea76d7ec4783320e6efdc45c468effb531c948a2292cL281-R298)
[[3]](diffhunk://#diff-f563baadcf750bb66efaea76d7ec4783320e6efdc45c468effb531c948a2292cL305-R311)
*
[`src/OpenFeature/EventExecutor.cs`](diffhunk://#diff-f563baadcf750bb66efaea76d7ec4783320e6efdc45c468effb531c948a2292cL219-R213):
Converted `ProcessFeatureProviderEventsAsync` and `ProcessEventAsync`
from `void` to `Task` to follow best practices for asynchronous methods.
[[1]](diffhunk://#diff-f563baadcf750bb66efaea76d7ec4783320e6efdc45c468effb531c948a2292cL219-R213)
[[2]](diffhunk://#diff-f563baadcf750bb66efaea76d7ec4783320e6efdc45c468effb531c948a2292cL237-R257)
### Related Issues
<!-- add here the GitHub issue that this PR resolves if applicable -->
Reference #358
---------
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>1 parent 9b6feab commit 46274a2
File tree
3 files changed
+101
-106
lines changed- src/OpenFeature
- Providers/Memory
- test/OpenFeature.Tests
3 files changed
+101
-106
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | | - | |
14 | | - | |
15 | 12 | | |
16 | 13 | | |
17 | | - | |
| 14 | + | |
18 | 15 | | |
19 | 16 | | |
20 | | - | |
21 | | - | |
| 17 | + | |
| 18 | + | |
22 | 19 | | |
23 | | - | |
24 | | - | |
| 20 | + | |
| 21 | + | |
25 | 22 | | |
26 | 23 | | |
27 | 24 | | |
28 | 25 | | |
29 | 26 | | |
30 | 27 | | |
31 | | - | |
32 | | - | |
| 28 | + | |
33 | 29 | | |
34 | 30 | | |
35 | 31 | | |
| |||
42 | 38 | | |
43 | 39 | | |
44 | 40 | | |
45 | | - | |
| 41 | + | |
46 | 42 | | |
47 | 43 | | |
48 | 44 | | |
| |||
70 | 66 | | |
71 | 67 | | |
72 | 68 | | |
73 | | - | |
| 69 | + | |
74 | 70 | | |
75 | 71 | | |
76 | 72 | | |
77 | 73 | | |
78 | 74 | | |
79 | | - | |
| 75 | + | |
80 | 76 | | |
81 | 77 | | |
82 | 78 | | |
| |||
127 | 123 | | |
128 | 124 | | |
129 | 125 | | |
130 | | - | |
131 | 126 | | |
132 | 127 | | |
133 | 128 | | |
134 | 129 | | |
135 | 130 | | |
136 | 131 | | |
137 | | - | |
| 132 | + | |
138 | 133 | | |
139 | | - | |
| 134 | + | |
140 | 135 | | |
141 | 136 | | |
142 | 137 | | |
| |||
146 | 141 | | |
147 | 142 | | |
148 | 143 | | |
149 | | - | |
150 | | - | |
| 144 | + | |
151 | 145 | | |
152 | 146 | | |
153 | 147 | | |
| |||
186 | 180 | | |
187 | 181 | | |
188 | 182 | | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
| 183 | + | |
195 | 184 | | |
196 | | - | |
197 | | - | |
198 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
199 | 192 | | |
200 | | - | |
| 193 | + | |
201 | 194 | | |
202 | 195 | | |
203 | | - | |
| 196 | + | |
204 | 197 | | |
205 | | - | |
| 198 | + | |
206 | 199 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
218 | 208 | | |
219 | 209 | | |
220 | 210 | | |
221 | | - | |
| 211 | + | |
222 | 212 | | |
223 | | - | |
224 | | - | |
| 213 | + | |
225 | 214 | | |
226 | 215 | | |
227 | 216 | | |
| |||
234 | 223 | | |
235 | 224 | | |
236 | 225 | | |
237 | | - | |
238 | | - | |
| 226 | + | |
| 227 | + | |
239 | 228 | | |
240 | 229 | | |
241 | 230 | | |
242 | 231 | | |
243 | 232 | | |
244 | 233 | | |
245 | | - | |
| 234 | + | |
246 | 235 | | |
247 | 236 | | |
248 | 237 | | |
249 | 238 | | |
| 239 | + | |
250 | 240 | | |
| 241 | + | |
251 | 242 | | |
252 | | - | |
| 243 | + | |
253 | 244 | | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
306 | 297 | | |
307 | 298 | | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
308 | 306 | | |
309 | 307 | | |
310 | 308 | | |
| 309 | + | |
311 | 310 | | |
312 | | - | |
| 311 | + | |
313 | 312 | | |
314 | 313 | | |
315 | 314 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | 155 | | |
161 | 156 | | |
0 commit comments