Skip to content

Commit 3c84c00

Browse files
committed
make pool size configurable
1 parent aa7a379 commit 3c84c00

File tree

2 files changed

+114
-7
lines changed

2 files changed

+114
-7
lines changed

Cargo.lock

+106
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

storage/src/backend/connection.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::str::FromStr;
1010
use std::sync::atomic::{AtomicBool, AtomicI16, AtomicU8, Ordering};
1111
use std::sync::Arc;
1212
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
13-
use std::{fmt, thread};
13+
use std::{fmt, thread, env};
1414

1515
use log::{max_level, Level};
1616

@@ -626,14 +626,19 @@ impl Connection {
626626
} else {
627627
None
628628
};
629+
// get pool size from envvar
630+
let pool_max_idle_per_host = match env::var("REGISTRY_CLIENT_POOL_MAX_IDLE_PER_HOST") {
631+
Ok(val) => val.parse::<usize>().unwrap_or(20),
632+
Err(_) => 20,
633+
};
629634

630635
let mut cb = Client::builder()
631636
.timeout(timeout)
632637
.connect_timeout(connect_timeout)
633638
.redirect(Policy::none());
634639
.use_rustls_tls()
635640
.tcp_keepalive(Some(Duration::from_secs(5 * 60)))
636-
.pool_max_idle_per_host(20);
641+
.pool_max_idle_per_host(pool_max_idle_per_host);
637642

638643
if config.skip_verify {
639644
cb = cb.danger_accept_invalid_certs(true);
@@ -642,11 +647,7 @@ impl Connection {
642647
if !proxy.is_empty() {
643648
cb = cb.proxy(reqwest::Proxy::all(proxy).map_err(|e| einval!(e))?)
644649
}
645-
debug!(
646-
"{} building connection with proxy: {}",
647-
std::thread::current().name().unwrap_or_default(),
648-
proxy
649-
);
650+
650651
cb.build().map_err(|e| einval!(e))
651652
}
652653

0 commit comments

Comments
 (0)