Commit 319f36f
committed
Prevent stacking of power requests
The power distributing actor processes one power request at a time
to prevent multiple requests for the same components from being sent
to the microgrid API concurrently. Previously, this could lead to
the request channel receiver becoming full if the power request
frequency was higher than the processing time. Even worse, the
requests could be processed late, causing unexpected behavior
for applications setting power requests. Moreover, the actor was
blocking power requests with different sets of components from being
processed if there was any existing request.
This patch ensures that the actor processes one request at a time
for different sets of components and keeps track of the latest pending
request if there is an existing request with the same set of
components being processed. The pending request will be overwritten
by the latest received request with the same set of components,
and the actor will process it once the request with the same components
is done processing.
Signed-off-by: Daniel Zullo <[email protected]>1 parent 60d6fde commit 319f36f
File tree
2 files changed
+78
-4
lines changed- src/frequenz/sdk/actor/power_distributing
- tests/timeseries/_battery_pool
2 files changed
+78
-4
lines changedLines changed: 64 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
100 | 114 | | |
101 | 115 | | |
102 | 116 | | |
| |||
135 | 149 | | |
136 | 150 | | |
137 | 151 | | |
138 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
139 | 164 | | |
140 | 165 | | |
141 | 166 | | |
| |||
146 | 171 | | |
147 | 172 | | |
148 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
216 | 217 | | |
217 | 218 | | |
218 | 219 | | |
| |||
248 | 249 | | |
249 | 250 | | |
250 | 251 | | |
| 252 | + | |
251 | 253 | | |
252 | 254 | | |
253 | 255 | | |
| |||
267 | 269 | | |
268 | 270 | | |
269 | 271 | | |
| 272 | + | |
270 | 273 | | |
271 | 274 | | |
272 | 275 | | |
| |||
318 | 321 | | |
319 | 322 | | |
320 | 323 | | |
| 324 | + | |
321 | 325 | | |
322 | 326 | | |
323 | 327 | | |
| |||
331 | 335 | | |
332 | 336 | | |
333 | 337 | | |
| 338 | + | |
334 | 339 | | |
335 | 340 | | |
336 | 341 | | |
| |||
375 | 380 | | |
376 | 381 | | |
377 | 382 | | |
378 | | - | |
| 383 | + | |
379 | 384 | | |
380 | 385 | | |
381 | 386 | | |
| |||
394 | 399 | | |
395 | 400 | | |
396 | 401 | | |
397 | | - | |
| 402 | + | |
398 | 403 | | |
399 | 404 | | |
400 | 405 | | |
| |||
428 | 433 | | |
429 | 434 | | |
430 | 435 | | |
| 436 | + | |
431 | 437 | | |
432 | 438 | | |
433 | 439 | | |
| |||
453 | 459 | | |
454 | 460 | | |
455 | 461 | | |
| 462 | + | |
456 | 463 | | |
457 | 464 | | |
458 | 465 | | |
| |||
477 | 484 | | |
478 | 485 | | |
479 | 486 | | |
| 487 | + | |
480 | 488 | | |
481 | 489 | | |
482 | 490 | | |
| |||
501 | 509 | | |
502 | 510 | | |
503 | 511 | | |
| 512 | + | |
504 | 513 | | |
505 | 514 | | |
506 | 515 | | |
| |||
586 | 595 | | |
587 | 596 | | |
588 | 597 | | |
589 | | - | |
| 598 | + | |
590 | 599 | | |
591 | 600 | | |
592 | 601 | | |
| |||
624 | 633 | | |
625 | 634 | | |
626 | 635 | | |
| 636 | + | |
627 | 637 | | |
628 | 638 | | |
629 | 639 | | |
| |||
664 | 674 | | |
665 | 675 | | |
666 | 676 | | |
| 677 | + | |
667 | 678 | | |
668 | 679 | | |
669 | 680 | | |
| |||
0 commit comments