Limit in-flight requests in chat app (#562)
This commit is contained in:
parent
d527050633
commit
aeaf13fc88
@ -48,6 +48,8 @@ use ratatui::{
|
|||||||
use tui_input::{backend::crossterm::EventHandler, Input};
|
use tui_input::{backend::crossterm::EventHandler, Input};
|
||||||
|
|
||||||
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(120);
|
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(120);
|
||||||
|
// Limit the number of maximum in-flight requests
|
||||||
|
const MAX_BUFFERED_REQUESTS: usize = 20;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Args)]
|
#[derive(Clone, Debug, Args)]
|
||||||
/// The almost-instant messaging protocol.
|
/// The almost-instant messaging protocol.
|
||||||
@ -299,7 +301,7 @@ async fn fetch_new_messages(
|
|||||||
|
|
||||||
process_block_blobs(node, block, da_settings)
|
process_block_blobs(node, block, da_settings)
|
||||||
})
|
})
|
||||||
.buffer_unordered(new_blocks.len())
|
.buffered(MAX_BUFFERED_REQUESTS)
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user