diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-02-23 17:31:29 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-02-23 17:31:29 +0100 |
commit | 2a084df300dc30d40cf3599c1cb7a90132d5a6e8 (patch) | |
tree | 302175b460a39a4752021d03afd9e7cccda1d56e /src | |
parent | 02a8537556236437d905cefe8aa2c5d0a96f129a (diff) | |
download | aerogramme-2a084df300dc30d40cf3599c1cb7a90132d5a6e8.tar.gz aerogramme-2a084df300dc30d40cf3599c1cb7a90132d5a6e8.zip |
Also share HTTPClient for K2Vperf/cpu-ram-bottleneck
Diffstat (limited to 'src')
-rw-r--r-- | src/login/ldap_provider.rs | 2 | ||||
-rw-r--r-- | src/login/static_provider.rs | 2 | ||||
-rw-r--r-- | src/storage/garage.rs | 38 |
3 files changed, 25 insertions, 17 deletions
diff --git a/src/login/ldap_provider.rs b/src/login/ldap_provider.rs index 42c993d..0af5676 100644 --- a/src/login/ldap_provider.rs +++ b/src/login/ldap_provider.rs @@ -96,7 +96,7 @@ impl LdapLoginProvider { //Login provider should return only a cryptoroot + a storage URI //storage URI that should be resolved outside... in_memory_store: storage::in_memory::MemDb::new(), - garage_store: storage::garage::GarageRoot::new(), + garage_store: storage::garage::GarageRoot::new()?, }) } diff --git a/src/login/static_provider.rs b/src/login/static_provider.rs index e190a91..79626df 100644 --- a/src/login/static_provider.rs +++ b/src/login/static_provider.rs @@ -85,7 +85,7 @@ impl StaticLoginProvider { Ok(Self { user_db: rx, in_memory_store: storage::in_memory::MemDb::new(), - garage_store: storage::garage::GarageRoot::new(), + garage_store: storage::garage::GarageRoot::new()?, }) } } diff --git a/src/storage/garage.rs b/src/storage/garage.rs index 870854a..a23bbb2 100644 --- a/src/storage/garage.rs +++ b/src/storage/garage.rs @@ -1,27 +1,29 @@ -use crate::storage::*; use aws_sdk_s3::{self as s3, error::SdkError, operation::get_object::GetObjectError}; use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder; use aws_smithy_runtime_api::client::http::SharedHttpClient; -//use hyper_rustls::HttpsConnector; -//use hyper_util::client::legacy::connect::HttpConnector; - - +use hyper_rustls::HttpsConnector; +use hyper_util::rt::TokioExecutor; +use hyper_util::client::legacy::{connect::HttpConnector, Client as HttpClient}; use serde::Serialize; +use crate::storage::*; + pub struct GarageRoot { + k2v_http: HttpClient<HttpsConnector<HttpConnector>, k2v_client::Body>, aws_http: SharedHttpClient, } impl GarageRoot { - pub fn new() -> Self { - /*let http = hyper_rustls::HttpsConnectorBuilder::new() - .https_or_http() - .with_native_roots() - .enable_http1() - .enable_http2() - .build();*/ + pub fn new() -> anyhow::Result<Self> { + let connector = hyper_rustls::HttpsConnectorBuilder::new() + .with_native_roots()? + .https_or_http() + .enable_http1() + .enable_http2() + .build(); + let k2v_http = HttpClient::builder(TokioExecutor::new()).build(connector); let aws_http = HyperClientBuilder::new().build_https(); - Self { aws_http } + Ok(Self { k2v_http, aws_http }) } pub fn user(&self, conf: GarageConf) -> anyhow::Result<Arc<GarageUser>> { @@ -29,7 +31,12 @@ impl GarageRoot { unicity.extend_from_slice(file!().as_bytes()); unicity.append(&mut rmp_serde::to_vec(&conf)?); - Ok(Arc::new(GarageUser { conf, aws_http: self.aws_http.clone(), unicity })) + Ok(Arc::new(GarageUser { + conf, + aws_http: self.aws_http.clone(), + k2v_http: self.k2v_http.clone(), + unicity + })) } } @@ -50,6 +57,7 @@ pub struct GarageConf { pub struct GarageUser { conf: GarageConf, aws_http: SharedHttpClient, + k2v_http: HttpClient<HttpsConnector<HttpConnector>, k2v_client::Body>, unicity: Vec<u8>, } @@ -87,7 +95,7 @@ impl IBuilder for GarageUser { user_agent: None, }; - let k2v_client = match k2v_client::K2vClient::new(k2v_config) { + let k2v_client = match k2v_client::K2vClient::new_with_client(k2v_config, self.k2v_http.clone()) { Err(e) => { tracing::error!("unable to build k2v client: {}", e); return Err(StorageError::Internal); |