tuwunel_core/config/appservice_client.rs
1//! Configures outgoing application-service transport.
2//!
3//! Request timeouts bound application-service calls. Idle connections have
4//! a separate pool lifetime.
5
6/// Outgoing application-service transport configuration.
7pub use Client as AppserviceClient;
8use serde::Deserialize;
9use tuwunel_macros::config_example_generator;
10
11/// Appservice HTTP client
12///
13/// Timeouts for the requests the server makes to appservices (bridges and
14/// bots). The defaults assume each appservice runs on the same host or
15/// network; raise `timeout` when one is remote or slow to answer.
16#[expect(rustdoc::broken_intra_doc_links, rustdoc::bare_urls)]
17#[derive(Clone, Copy, Debug, Deserialize)]
18#[config_example_generator(
19 filename = "tuwunel-example.toml",
20 section = "global.appservice_client",
21 group = "true"
22)]
23pub struct Client {
24 /// Sets appservice URL read and total timeouts in seconds, defaulting to
25 /// 35 because appservices are generally hosted on the same network.
26 ///
27 /// default: 35
28 /// legacy: appservice_timeout
29 #[serde(default = "default_timeout")]
30 pub timeout: u64,
31
32 /// Sets the appservice URL idle connection-pool timeout in seconds.
33 ///
34 /// default: 300
35 /// legacy: appservice_idle_timeout
36 #[serde(default = "default_idle_timeout")]
37 pub idle_timeout: u64,
38}
39
40impl Default for Client {
41 fn default() -> Self {
42 Self {
43 timeout: default_timeout(),
44 idle_timeout: default_idle_timeout(),
45 }
46 }
47}
48
49fn default_timeout() -> u64 { 35 }
50
51fn default_idle_timeout() -> u64 { 300 }