Move default private connect timeout to `Config` (#42)
Previously the default value of this setting was in lib.rs instead of being automatically set in `Config` like all the other defaults, which was inconsistent and confusing. Fix this by moving the defaulting logic to `Config`. Validated by running the test suite.
This commit is contained in:
parent
284fbcfb20
commit
95cb05d3a9
|
@ -32,7 +32,7 @@ pub struct Config {
|
||||||
pub public_connect_timeout: Option<Duration>,
|
pub public_connect_timeout: Option<Duration>,
|
||||||
|
|
||||||
/// The maximum amount of time to wait for a connection to the private peer.
|
/// The maximum amount of time to wait for a connection to the private peer.
|
||||||
pub private_connect_timeout: Option<Duration>,
|
pub private_connect_timeout: Duration,
|
||||||
|
|
||||||
/// The path to "/etc/resolv.conf"
|
/// The path to "/etc/resolv.conf"
|
||||||
pub resolv_conf_path: PathBuf,
|
pub resolv_conf_path: PathBuf,
|
||||||
|
@ -143,6 +143,7 @@ const DEFAULT_REPORT_TIMEOUT_SECS: u64 = 10; // TODO: is this a reasonable defau
|
||||||
const DEFAULT_PRIVATE_LISTENER: &str = "tcp://127.0.0.1:4140";
|
const DEFAULT_PRIVATE_LISTENER: &str = "tcp://127.0.0.1:4140";
|
||||||
const DEFAULT_PUBLIC_LISTENER: &str = "tcp://0.0.0.0:4143";
|
const DEFAULT_PUBLIC_LISTENER: &str = "tcp://0.0.0.0:4143";
|
||||||
const DEFAULT_CONTROL_LISTENER: &str = "tcp://0.0.0.0:4190";
|
const DEFAULT_CONTROL_LISTENER: &str = "tcp://0.0.0.0:4190";
|
||||||
|
const DEFAULT_PRIVATE_CONNECT_TIMEOUT_MS: u64 = 20;
|
||||||
const DEFAULT_CONTROL_URL: &str = "tcp://proxy-api.conduit.svc.cluster.local:8086";
|
const DEFAULT_CONTROL_URL: &str = "tcp://proxy-api.conduit.svc.cluster.local:8086";
|
||||||
const DEFAULT_RESOLV_CONF: &str = "/etc/resolv.conf";
|
const DEFAULT_RESOLV_CONF: &str = "/etc/resolv.conf";
|
||||||
|
|
||||||
|
@ -186,7 +187,9 @@ impl<'a> TryFrom<&'a Strings> for Config {
|
||||||
},
|
},
|
||||||
private_forward: private_forward?,
|
private_forward: private_forward?,
|
||||||
public_connect_timeout: public_connect_timeout?.map(Duration::from_millis),
|
public_connect_timeout: public_connect_timeout?.map(Duration::from_millis),
|
||||||
private_connect_timeout: private_connect_timeout?.map(Duration::from_millis),
|
private_connect_timeout:
|
||||||
|
Duration::from_millis(private_connect_timeout?
|
||||||
|
.unwrap_or(DEFAULT_PRIVATE_CONNECT_TIMEOUT_MS)),
|
||||||
resolv_conf_path: resolv_conf_path?
|
resolv_conf_path: resolv_conf_path?
|
||||||
.unwrap_or(DEFAULT_RESOLV_CONF.into())
|
.unwrap_or(DEFAULT_RESOLV_CONF.into())
|
||||||
.into(),
|
.into(),
|
||||||
|
|
|
@ -46,7 +46,7 @@ use std::io;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::Instant;
|
||||||
|
|
||||||
use tokio_core::reactor::{Core, Handle};
|
use tokio_core::reactor::{Core, Handle};
|
||||||
use tower::NewService;
|
use tower::NewService;
|
||||||
|
@ -176,11 +176,8 @@ impl Main {
|
||||||
let inbound = {
|
let inbound = {
|
||||||
let ctx = ctx::Proxy::inbound(&process_ctx);
|
let ctx = ctx::Proxy::inbound(&process_ctx);
|
||||||
|
|
||||||
let timeout = config
|
|
||||||
.private_connect_timeout
|
|
||||||
.unwrap_or_else(|| Duration::from_millis(20));
|
|
||||||
let bind = bind.clone()
|
let bind = bind.clone()
|
||||||
.with_connect_timeout(timeout)
|
.with_connect_timeout(config.private_connect_timeout)
|
||||||
.with_ctx(ctx.clone());
|
.with_ctx(ctx.clone());
|
||||||
|
|
||||||
let default_addr = config.private_forward.map(|a| a.into());
|
let default_addr = config.private_forward.map(|a| a.into());
|
||||||
|
|
Loading…
Reference in New Issue