Skip to content

Commit

Permalink
make pool size configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
technillogue committed Jul 18, 2023
1 parent aa7a379 commit 3c84c00
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 7 deletions.
106 changes: 106 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions storage/src/backend/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::str::FromStr;
use std::sync::atomic::{AtomicBool, AtomicI16, AtomicU8, Ordering};
use std::sync::Arc;
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
use std::{fmt, thread};
use std::{fmt, thread, env};

use log::{max_level, Level};

Expand Down Expand Up @@ -626,14 +626,19 @@ impl Connection {
} else {
None
};
// get pool size from envvar
let pool_max_idle_per_host = match env::var("REGISTRY_CLIENT_POOL_MAX_IDLE_PER_HOST") {
Ok(val) => val.parse::<usize>().unwrap_or(20),
Err(_) => 20,
};

let mut cb = Client::builder()
.timeout(timeout)
.connect_timeout(connect_timeout)
.redirect(Policy::none());
.use_rustls_tls()
.tcp_keepalive(Some(Duration::from_secs(5 * 60)))
.pool_max_idle_per_host(20);
.pool_max_idle_per_host(pool_max_idle_per_host);

if config.skip_verify {
cb = cb.danger_accept_invalid_certs(true);
Expand All @@ -642,11 +647,7 @@ impl Connection {
if !proxy.is_empty() {
cb = cb.proxy(reqwest::Proxy::all(proxy).map_err(|e| einval!(e))?)
}
debug!(
"{} building connection with proxy: {}",
std::thread::current().name().unwrap_or_default(),
proxy
);

cb.build().map_err(|e| einval!(e))
}

Expand Down

0 comments on commit 3c84c00

Please sign in to comment.