1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-26 10:44:51 +03:00

Make the HTTP client factory reuse the underlying client

This avoids duplicating clients, and makes it so that they all share the same connection pool.
This commit is contained in:
Quentin Gliech
2023-09-14 14:22:49 +02:00
parent f29e4adcfa
commit 54071c4969
15 changed files with 146 additions and 77 deletions

View File

@@ -67,7 +67,7 @@ impl Options {
#[tracing::instrument(skip_all)]
pub async fn run(self, root: &super::Options) -> anyhow::Result<()> {
use Subcommand as SC;
let http_client_factory = HttpClientFactory::new(10);
let http_client_factory = HttpClientFactory::new().await?;
match self.subcommand {
SC::Http {
show_headers,
@@ -75,7 +75,7 @@ impl Options {
url,
} => {
let _span = info_span!("cli.debug.http").entered();
let mut client = http_client_factory.client().await?;
let mut client = http_client_factory.client("debug");
let request = hyper::Request::builder()
.uri(url)
.body(hyper::Body::empty())?;
@@ -99,8 +99,7 @@ impl Options {
} => {
let _span = info_span!("cli.debug.http").entered();
let mut client = http_client_factory
.client()
.await?
.client("debug")
.response_body_to_bytes()
.json_response();
let request = hyper::Request::builder()