Skip to content

Commit

Permalink
add debugging and keylogfile
Browse files Browse the repository at this point in the history
  • Loading branch information
brayniac committed Oct 7, 2024
1 parent 30d4dd2 commit f17f1f5
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions src/clients/cache/momento/http.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use rustls::KeyLogFile;
use crate::clients::common::*;
use crate::workload::{ClientRequest, ClientWorkItemKind};
use crate::*;
Expand Down Expand Up @@ -56,11 +57,13 @@ pub async fn pool_manager(endpoint: String, _config: Config, queue: Queue<SendRe
roots: webpki_roots::TLS_SERVER_ROOTS.into(),
};

let config = Arc::new(
rustls::ClientConfig::builder()
.with_root_certificates(root_store)
.with_no_client_auth(),
);
let mut config = rustls::ClientConfig::builder()
.with_root_certificates(root_store)
.with_no_client_auth();

config.key_log = Arc::new(KeyLogFile::new());

let config = Arc::new(config);

while RUNNING.load(Ordering::Relaxed) {
if client.is_none() {
Expand Down Expand Up @@ -175,7 +178,7 @@ async fn task(
Ok((response, _)) => {
let response = response.await;

let response = match response {
let mut response = match response {
Ok(r) => r,
Err(_e) => {
GET_EX.increment();
Expand All @@ -188,14 +191,21 @@ async fn task(

let status = response.status().as_u16();

info!("get status: {status}");

// read the response body to completion

let mut buffer = BytesMut::new();
let mut body = response.into_body();
// let mut body = response.into_body();

while let Some(chunk) = body.data().await {
while let Some(chunk) = response.body_mut().data().await {
if let Ok(b) = chunk {
info!("chunk for get: {}", b.len());
buffer.extend_from_slice(&b);

// if body.is_end_stream() {
// info!("end of stream");
// }
} else {
GET_EX.increment();

Expand All @@ -205,6 +215,8 @@ async fn task(
}
}

info!("get complete");

let latency = start.elapsed();

REQUEST_OK.increment();
Expand Down Expand Up @@ -269,7 +281,7 @@ async fn task(
let response = match response {
Ok(r) => r,
Err(_e) => {
GET_EX.increment();
SET_EX.increment();

RESPONSE_EX.increment();

Expand All @@ -279,13 +291,16 @@ async fn task(

let status = response.status().as_u16();

info!("set status: {status}");

// read the response body to completion

let mut buffer = BytesMut::new();
let mut body = response.into_body();

while let Some(chunk) = body.data().await {
if let Ok(b) = chunk {
info!("chunk for set: {}", b.len());
buffer.extend_from_slice(&b);
} else {
GET_EX.increment();
Expand All @@ -296,6 +311,8 @@ async fn task(
}
}

info!("set complete");

let latency = start.elapsed();

REQUEST_OK.increment();
Expand Down Expand Up @@ -349,23 +366,28 @@ async fn task(

let status = response.status().as_u16();

info!("delete status: {status}");

// read the response body to completion

let mut buffer = BytesMut::new();
let mut body = response.into_body();

while let Some(chunk) = body.data().await {
if let Ok(b) = chunk {
info!("chunk for delete: {}", b.len());
buffer.extend_from_slice(&b);
} else {
GET_EX.increment();
DELETE_EX.increment();

RESPONSE_EX.increment();

continue;
}
}

info!("delete complete");

let latency = start.elapsed();

REQUEST_OK.increment();
Expand Down

0 comments on commit f17f1f5

Please sign in to comment.