Limit flood if intervals in stream
This commit is contained in:
parent
b12bbc45c8
commit
edbd13249c
1 changed files with 3 additions and 2 deletions
|
@ -5,9 +5,10 @@ fn main() {
|
|||
trpl::run(async {
|
||||
let messages = get_messages().timeout(Duration::from_millis(200));
|
||||
let intervals = get_intervals()
|
||||
.map(|count| format!("Interval: {count}"))
|
||||
.map(|count| format!("Interval #{count}"))
|
||||
.throttle(Duration::from_millis(100))
|
||||
.timeout(Duration::from_secs(10));
|
||||
let merged = messages.merge(intervals);
|
||||
let merged = messages.merge(intervals).take(20);
|
||||
let mut stream = pin!(merged);
|
||||
|
||||
while let Some(result) = stream.next().await {
|
||||
|
|
Loading…
Reference in a new issue