Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port RedisSinkSingle to try_recv #1620

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions shotover/src/transforms/redis/sink_single.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ impl Transform for RedisSinkSingle {
}

let mut responses = vec![];

if requests_wrapper.requests.is_empty() {
// there are no requests, so no point sending any, but we should check for any responses without awaiting
// TODO: handle errors here
Expand All @@ -147,31 +148,23 @@ impl Transform for RedisSinkSingle {
}
}
} else {
let requests_count = requests_wrapper.requests.len();
self.connection
.as_mut()
.unwrap()
.send(requests_wrapper.requests)?;

let mut responses_count = 0;
while responses_count < requests_count {
let responses_len_old = responses.len();
self.connection
.as_mut()
.unwrap()
.recv_into(&mut responses)
.await?;
self.connection
.as_mut()
.unwrap()
.try_recv_into(&mut responses)?;

for response in &mut responses[responses_len_old..] {
if let Some(Frame::Redis(RedisFrame::Error(_))) = response.frame() {
self.failed_requests.increment(1);
}
if response.request_id().is_some() {
responses_count += 1;
}
for response in &mut responses {
if let Some(Frame::Redis(RedisFrame::Error(_))) = response.frame() {
self.failed_requests.increment(1);
}
}
}

Ok(responses)
}
}
Loading