Commit c4e0fd2
authored
refactor(http/retry): outline bounded replay buffer (#3597)
the `ReplayBody<B>` middleware makes use of a `BufList` type to hold a
reference to bytes yielded by the inner body `B`. a `Data` enum is
composed on top to this, to allow bodies to either return (a) a replay
of a previous body, or (b) the iniial bytes yielded by the original
body.
this branch also takes the step of moving some code out of the
`ReplayBody::poll_data(..)` trait method along with inlining
`BufList::push_chunk(..)` , a small helper function that is only used
once.
this is intended to consolidate code related to buffering data yielded
by the underlying `B`-typed body, and extricate logic concerning the
bounding of this buffer from the now defunct `Body::poll_data()` trait
method.
see linkerd/linkerd2#8733 for more information
about upgrading the proxy to hyper 1.0.
this will help make subsequent changes to the model of `ReplayBody<B>`
its corresponding `Body` implementation more reviewable, by proactively
reorganizing things in advance.
---
* refactor(http/retry): outline replay buffer
the replay body uses this `BufList` type to hold a reference to bytes
yielded by the inner body `B`.
the `Data` enum is composed on top to this, to allow bodies to either
return a replay of a previous body, or the iniial bytes yielded by the
original body.
this is all relatively self-contained, so we can move this into a small
submodule.
Signed-off-by: katelyn martin <kate@buoyant.io>
* refactor(http/retry): outline replay body buffering
this commit moves some code out of the `ReplayBody::poll_data(..)` trait
method.
this bit of code is where we take a chunk of a data yielded by the inner
body, and push it into our replay buffer. if the capacity is exceeded,
we flush the buffer. in either case, the code copies the chunk into a
cheaply cloneable, contiguous `Bytes`.
this is all related to the buffer, so we move it there.
Signed-off-by: katelyn martin <kate@buoyant.io>
* refactor(http/retry): inline `BufList::push_chunk`
`push_chunk` is a small helper function that is only used once. now that
we have moved our buffering code alongside this type, it's more
straightforward to inline this function.
Signed-off-by: katelyn martin <kate@buoyant.io>
* refactor(http/retry): rename `BufList` to `Replay`
this structure is responsible for acting as the `bytes::Buf` buffer for
the replay of the initial body.
this commit renames this to articulate that relationship more directly.
Signed-off-by: katelyn martin <kate@buoyant.io>
* docs(http/retry): polish `Replay` documentation
Signed-off-by: katelyn martin <kate@buoyant.io>
---------
Signed-off-by: katelyn martin <kate@buoyant.io>1 parent 4f7f715 commit c4e0fd2
2 files changed
+192
-176
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| |||
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | 53 | | |
65 | 54 | | |
66 | 55 | | |
| |||
77 | 66 | | |
78 | 67 | | |
79 | 68 | | |
80 | | - | |
| 69 | + | |
81 | 70 | | |
82 | 71 | | |
83 | 72 | | |
| |||
113 | 102 | | |
114 | 103 | | |
115 | 104 | | |
116 | | - | |
| 105 | + | |
117 | 106 | | |
118 | 107 | | |
119 | 108 | | |
| |||
180 | 169 | | |
181 | 170 | | |
182 | 171 | | |
183 | | - | |
| 172 | + | |
184 | 173 | | |
185 | 174 | | |
186 | 175 | | |
| |||
189 | 178 | | |
190 | 179 | | |
191 | 180 | | |
192 | | - | |
| 181 | + | |
193 | 182 | | |
194 | 183 | | |
195 | 184 | | |
196 | | - | |
| 185 | + | |
197 | 186 | | |
198 | 187 | | |
199 | 188 | | |
| |||
215 | 204 | | |
216 | 205 | | |
217 | 206 | | |
218 | | - | |
| 207 | + | |
219 | 208 | | |
220 | 209 | | |
221 | 210 | | |
| |||
230 | 219 | | |
231 | 220 | | |
232 | 221 | | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
| 222 | + | |
250 | 223 | | |
251 | | - | |
| 224 | + | |
252 | 225 | | |
253 | 226 | | |
254 | 227 | | |
| |||
324 | 297 | | |
325 | 298 | | |
326 | 299 | | |
327 | | - | |
| 300 | + | |
328 | 301 | | |
329 | 302 | | |
330 | 303 | | |
| |||
361 | 334 | | |
362 | 335 | | |
363 | 336 | | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | 337 | | |
499 | 338 | | |
500 | 339 | | |
| |||
0 commit comments