Commit e595df4
authored
Add a broadcast async sequence (#1684)
Motivation:
To support retries and hedging we need a way to buffer elements over
time that can support multiple consumers concurrently and allows for
consumers to start consuming after some elements have been produced.
An `AsyncSequence` fits this quite naturally but we don't yet have a
general purpose implementat that fits this requirement. This change
adds `BroadcastAsyncSequence` which isn't a general purpose async
sequence but instead is tailored to the needs of grpc for hedging and
retries. This means it supports a low number of concurrent iterators and
maintains a limited size internal buffer and drops the slowest consumers
when the buffer becomes full.
Modifications:
- Add a `BroadcastAsyncSequence` and tests
- Made a bunch of things inlinable/usableFromInline which necessitated a
switch from `@_spi(Testing)` to `@testable` imports.
- Rename the 'Stream' directory to 'Streaming'
Result:
- `BroadcastAsyncSequence` can be used to implement retries and hedging.1 parent 6ccafcc commit e595df4
File tree
11 files changed
+2034
-14
lines changed- Sources/GRPCCore
- Call/Client
- Streaming
- Internal
- Tests/GRPCCoreTests
- Call/Client
- Streaming/Internal
- Test Utilities
11 files changed
+2034
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
374 | | - | |
375 | | - | |
| 374 | + | |
376 | 375 | | |
377 | 376 | | |
378 | 377 | | |
| |||
Lines changed: 16 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
| 26 | + | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | | - | |
35 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
| 39 | + | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
| 49 | + | |
45 | 50 | | |
46 | | - | |
| 51 | + | |
| 52 | + | |
47 | 53 | | |
48 | | - | |
| 54 | + | |
| 55 | + | |
49 | 56 | | |
50 | 57 | | |
51 | 58 | | |
| 59 | + | |
52 | 60 | | |
53 | 61 | | |
54 | 62 | | |
| |||
0 commit comments