schema_registry_client/rest/
client_config.rs1#[derive(Clone, Debug)]
2pub struct ClientConfig {
3 pub base_urls: Vec<String>,
4
5 pub basic_auth: Option<BasicAuth>,
6 pub bearer_access_token: Option<String>,
7
8 pub cache_capacity: u64,
9 pub cache_latest_ttl_sec: u64,
10
11 pub max_retries: u32,
12 pub retries_wait_ms: u32,
13 pub retries_max_wait_ms: u32,
14
15 pub client: reqwest::Client,
16}
17
18pub type BasicAuth = (String, Option<String>);
19
20impl ClientConfig {
21 pub fn new(base_urls: Vec<String>) -> Self {
22 ClientConfig {
23 base_urls,
24 basic_auth: None,
25 bearer_access_token: None,
26 cache_capacity: 1000,
27 cache_latest_ttl_sec: 60,
28 max_retries: 2,
29 retries_wait_ms: 1000,
30 retries_max_wait_ms: 20000,
31 client: reqwest::Client::new(),
32 }
33 }
34}
35
36impl Default for ClientConfig {
37 fn default() -> Self {
38 ClientConfig {
39 base_urls: vec!["http://localhost:8081".to_string()],
40 basic_auth: None,
41 bearer_access_token: None,
42 cache_capacity: 1000,
43 cache_latest_ttl_sec: 60,
44 max_retries: 2,
45 retries_wait_ms: 1000,
46 retries_max_wait_ms: 20000,
47 client: reqwest::Client::new(),
48 }
49 }
50}
51
52impl PartialEq for ClientConfig {
53 fn eq(&self, other: &Self) -> bool {
54 self.base_urls == other.base_urls
55 && self.basic_auth == other.basic_auth
56 && self.bearer_access_token == other.bearer_access_token
57 && self.max_retries == other.max_retries
58 && self.retries_wait_ms == other.retries_wait_ms
59 && self.retries_max_wait_ms == other.retries_max_wait_ms
60 }
61}