From 05e82a2da9aa1877731764ba2463bf5bcd2a261d Mon Sep 17 00:00:00 2001 From: neonphog Date: Wed, 14 Aug 2024 16:12:23 -0600 Subject: [PATCH] configurable slow_app_timeout defaulting to ~1s --- Cargo.lock | 18 +++++++++--------- Cargo.toml | 14 +++++++------- crates/tx5-connection/Cargo.toml | 2 +- crates/tx5-connection/src/lib.rs | 14 +++++++------- crates/tx5-core/Cargo.toml | 2 +- crates/tx5-core/src/lib.rs | 5 +++++ crates/tx5-demo/Cargo.toml | 2 +- crates/tx5-go-pion-sys/Cargo.toml | 2 +- crates/tx5-go-pion-turn/Cargo.toml | 2 +- crates/tx5-go-pion/Cargo.toml | 2 +- crates/tx5-online/Cargo.toml | 2 +- crates/tx5-signal/Cargo.toml | 2 +- crates/tx5/Cargo.toml | 2 +- 13 files changed, 37 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6faa4016..f91e9f69 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2824,7 +2824,7 @@ dependencies = [ [[package]] name = "tx5" -version = "0.1.2-beta" +version = "0.1.3-beta" dependencies = [ "base64 0.22.1", "criterion", @@ -2843,7 +2843,7 @@ dependencies = [ [[package]] name = "tx5-connection" -version = "0.1.2-beta" +version = "0.1.3-beta" dependencies = [ "bit_field", "futures", @@ -2859,7 +2859,7 @@ dependencies = [ [[package]] name = "tx5-core" -version = "0.1.2-beta" +version = "0.1.3-beta" dependencies = [ "app_dirs2", "base64 0.22.1", @@ -2876,7 +2876,7 @@ dependencies = [ [[package]] name = "tx5-demo" -version = "0.1.2-beta" +version = "0.1.3-beta" dependencies = [ "base64 0.22.1", "bytes", @@ -2898,7 +2898,7 @@ dependencies = [ [[package]] name = "tx5-go-pion" -version = "0.1.2-beta" +version = "0.1.3-beta" dependencies = [ "futures", "parking_lot", @@ -2913,7 +2913,7 @@ dependencies = [ [[package]] name = "tx5-go-pion-sys" -version = "0.1.2-beta" +version = "0.1.3-beta" dependencies = [ "Inflector", "base64 0.22.1", @@ -2931,7 +2931,7 @@ dependencies = [ [[package]] name = "tx5-go-pion-turn" -version = "0.1.2-beta" +version = "0.1.3-beta" dependencies = [ "base64 0.22.1", "dirs", @@ -2948,7 +2948,7 @@ dependencies = [ [[package]] name = "tx5-online" -version = "0.1.2-beta" +version = "0.1.3-beta" dependencies = [ "once_cell", "rand", @@ -2959,7 +2959,7 @@ dependencies = [ [[package]] name = "tx5-signal" -version = "0.1.2-beta" +version = "0.1.3-beta" dependencies = [ "rand", "sbd-e2e-crypto-client", diff --git a/Cargo.toml b/Cargo.toml index ee94ef1a..4029a584 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } diff --git a/crates/tx5-connection/Cargo.toml b/crates/tx5-connection/Cargo.toml index 74f6aada..a7a8f3eb 100644 --- a/crates/tx5-connection/Cargo.toml +++ b/crates/tx5-connection/Cargo.toml @@ -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" diff --git a/crates/tx5-connection/src/lib.rs b/crates/tx5-connection/src/lib.rs index 41da361b..45133093 100644 --- a/crates/tx5-connection/src/lib.rs +++ b/crates/tx5-connection/src/lib.rs @@ -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)*} @@ -145,7 +140,12 @@ impl CloseSend { 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" diff --git a/crates/tx5-core/Cargo.toml b/crates/tx5-core/Cargo.toml index 66f86641..74bc18c3 100644 --- a/crates/tx5-core/Cargo.toml +++ b/crates/tx5-core/Cargo.toml @@ -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" diff --git a/crates/tx5-core/src/lib.rs b/crates/tx5-core/src/lib.rs index f3c12ab3..29808ecc 100644 --- a/crates/tx5-core/src/lib.rs +++ b/crates/tx5-core/src/lib.rs @@ -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 { @@ -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), } } } diff --git a/crates/tx5-demo/Cargo.toml b/crates/tx5-demo/Cargo.toml index 220c5b0c..cfd26684 100644 --- a/crates/tx5-demo/Cargo.toml +++ b/crates/tx5-demo/Cargo.toml @@ -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" diff --git a/crates/tx5-go-pion-sys/Cargo.toml b/crates/tx5-go-pion-sys/Cargo.toml index c5af251c..3410e880 100644 --- a/crates/tx5-go-pion-sys/Cargo.toml +++ b/crates/tx5-go-pion-sys/Cargo.toml @@ -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" diff --git a/crates/tx5-go-pion-turn/Cargo.toml b/crates/tx5-go-pion-turn/Cargo.toml index f271a6f9..c061d94f 100644 --- a/crates/tx5-go-pion-turn/Cargo.toml +++ b/crates/tx5-go-pion-turn/Cargo.toml @@ -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" diff --git a/crates/tx5-go-pion/Cargo.toml b/crates/tx5-go-pion/Cargo.toml index 76c759ec..6fea3bd1 100644 --- a/crates/tx5-go-pion/Cargo.toml +++ b/crates/tx5-go-pion/Cargo.toml @@ -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" diff --git a/crates/tx5-online/Cargo.toml b/crates/tx5-online/Cargo.toml index deae3dac..9273e9b8 100644 --- a/crates/tx5-online/Cargo.toml +++ b/crates/tx5-online/Cargo.toml @@ -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" diff --git a/crates/tx5-signal/Cargo.toml b/crates/tx5-signal/Cargo.toml index 6bb3f81f..a2059c3d 100644 --- a/crates/tx5-signal/Cargo.toml +++ b/crates/tx5-signal/Cargo.toml @@ -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" diff --git a/crates/tx5/Cargo.toml b/crates/tx5/Cargo.toml index ec64912f..3c13e8aa 100644 --- a/crates/tx5/Cargo.toml +++ b/crates/tx5/Cargo.toml @@ -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"