Skip to content

Commit

Permalink
configurable slow_app_timeout defaulting to ~1s
Browse files Browse the repository at this point in the history
  • Loading branch information
neonphog committed Aug 14, 2024
1 parent 2d01c7b commit 05e82a2
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 32 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ tracing = "0.1.37"
tracing-appender = "0.2.2"
tracing-subscriber = { version = "0.3.16", features = [ "env-filter" ] }
trust-dns-resolver = "0.22.0"
tx5-connection = { version = "0.1.2-beta", default-features = false, path = "crates/tx5-connection" }
tx5-core = { version = "0.1.2-beta", default-features = false, path = "crates/tx5-core" }
tx5-go-pion-turn = { version = "0.1.2-beta", path = "crates/tx5-go-pion-turn" }
tx5-go-pion-sys = { version = "0.1.2-beta", path = "crates/tx5-go-pion-sys" }
tx5-go-pion = { version = "0.1.2-beta", path = "crates/tx5-go-pion" }
tx5-signal = { version = "0.1.2-beta", path = "crates/tx5-signal" }
tx5 = { version = "0.1.2-beta", path = "crates/tx5" }
tx5-connection = { version = "0.1.3-beta", default-features = false, path = "crates/tx5-connection" }
tx5-core = { version = "0.1.3-beta", default-features = false, path = "crates/tx5-core" }
tx5-go-pion-turn = { version = "0.1.3-beta", path = "crates/tx5-go-pion-turn" }
tx5-go-pion-sys = { version = "0.1.3-beta", path = "crates/tx5-go-pion-sys" }
tx5-go-pion = { version = "0.1.3-beta", path = "crates/tx5-go-pion" }
tx5-signal = { version = "0.1.3-beta", path = "crates/tx5-signal" }
tx5 = { version = "0.1.3-beta", path = "crates/tx5" }
url = { version = "2.3.1", features = [ "serde" ] }
warp = { version = "0.3.4", features = [ "websocket" ] }
webpki-roots = { version = "0.23.0" }
Expand Down
2 changes: 1 addition & 1 deletion crates/tx5-connection/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tx5-connection"
version = "0.1.2-beta"
version = "0.1.3-beta"
description = "holochain webrtc connection"
license = "MIT OR Apache-2.0"
homepage = "https://github.com/holochain/tx5"
Expand Down
14 changes: 7 additions & 7 deletions crates/tx5-connection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,10 @@ compile_error!("Must specify exactly 1 webrtc backend");
#[cfg(feature = "backend-go-pion")]
pub use tx5_go_pion::Tx5InitConfig;

/// Grace time to allow a slow app to catch up before we close a
/// connection to prevent our memory from filling up with backlogged
/// message data.
const SLOW_APP_TO: std::time::Duration = std::time::Duration::from_millis(99);

macro_rules! breakable_timeout {
($($t:tt)*) => {
tokio::time::timeout(
$crate::SLOW_APP_TO,
::tx5_core::Tx5InitConfig::get().slow_app_timeout,
async {
loop {
{$($t)*}
Expand Down Expand Up @@ -145,7 +140,12 @@ impl<T: 'static + Send> CloseSend<T> {
async move {
match s {
Some(mut s) => {
match tokio::time::timeout(SLOW_APP_TO, s.send(t)).await {
match tokio::time::timeout(
tx5_core::Tx5InitConfig::get().slow_app_timeout,
s.send(t),
)
.await
{
Err(_) => {
tracing::warn!(
"Closing connection due to slow app"
Expand Down
2 changes: 1 addition & 1 deletion crates/tx5-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tx5-core"
version = "0.1.2-beta"
version = "0.1.3-beta"
edition = "2021"
description = "Holochain WebRTC P2P Communication Ecosystem Core Types"
license = "MIT OR Apache-2.0"
Expand Down
5 changes: 5 additions & 0 deletions crates/tx5-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ pub struct Tx5InitConfig {

/// The maximum ephemeral udp port to bind. Defaults to `65535`.
pub ephemeral_udp_port_max: u16,

/// The maximum time allowed for application calls to complete.
/// Defaults to 999ms (~1 second).
pub slow_app_timeout: std::time::Duration,
}

impl Default for Tx5InitConfig {
Expand All @@ -50,6 +54,7 @@ impl Default for Tx5InitConfig {
tracing_enabled: false,
ephemeral_udp_port_min: 1,
ephemeral_udp_port_max: 65535,
slow_app_timeout: std::time::Duration::from_millis(999),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/tx5-demo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tx5-demo"
version = "0.1.2-beta"
version = "0.1.3-beta"
edition = "2021"
description = "Demo crate showing off Tx5 WebRTC functionality"
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/tx5-go-pion-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tx5-go-pion-sys"
version = "0.1.2-beta"
version = "0.1.3-beta"
edition = "2021"
description = "Low level rust bindings to the go pion webrtc library"
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/tx5-go-pion-turn/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tx5-go-pion-turn"
version = "0.1.2-beta"
version = "0.1.3-beta"
edition = "2021"
description = "Rust process wrapper around tx5-go-pion-turn executable"
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/tx5-go-pion/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tx5-go-pion"
version = "0.1.2-beta"
version = "0.1.3-beta"
edition = "2021"
description = "Rust bindings to the go pion webrtc library"
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/tx5-online/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tx5-online"
version = "0.1.2-beta"
version = "0.1.3-beta"
edition = "2021"
description = "Holochain WebRTC P2P Communication Ecosystem Online Connectivity Events"
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/tx5-signal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tx5-signal"
version = "0.1.2-beta"
version = "0.1.3-beta"
description = "holochain webrtc signal client"
license = "MIT OR Apache-2.0"
homepage = "https://github.com/holochain/tx5"
Expand Down
2 changes: 1 addition & 1 deletion crates/tx5/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tx5"
version = "0.1.2-beta"
version = "0.1.3-beta"
edition = "2021"
description = "The main holochain tx5 webrtc networking crate"
license = "MIT OR Apache-2.0"
Expand Down

0 comments on commit 05e82a2

Please sign in to comment.