tower_a2a/client/
config.rs

1//! Client configuration
2
3use std::time::Duration;
4
5/// Configuration for an A2A client
6#[derive(Debug, Clone)]
7pub struct ClientConfig {
8    /// Base URL of the agent
9    pub agent_url: String,
10
11    /// Default request timeout
12    pub timeout: Duration,
13
14    /// Maximum number of retry attempts
15    pub max_retries: u32,
16
17    /// Enable response validation
18    pub validate_responses: bool,
19}
20
21impl ClientConfig {
22    /// Create a new client configuration
23    pub fn new(agent_url: impl Into<String>) -> Self {
24        Self {
25            agent_url: agent_url.into(),
26            timeout: Duration::from_secs(30),
27            max_retries: 3,
28            validate_responses: true,
29        }
30    }
31
32    /// Set the timeout
33    pub fn with_timeout(mut self, timeout: Duration) -> Self {
34        self.timeout = timeout;
35        self
36    }
37
38    /// Set the maximum number of retries
39    pub fn with_max_retries(mut self, max_retries: u32) -> Self {
40        self.max_retries = max_retries;
41        self
42    }
43
44    /// Enable or disable response validation
45    pub fn with_validation(mut self, enabled: bool) -> Self {
46        self.validate_responses = enabled;
47        self
48    }
49}
50
51impl Default for ClientConfig {
52    fn default() -> Self {
53        Self::new("")
54    }
55}