Skip to content

Commit

Permalink
workers return only one response when dispatching a request
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Dec 12, 2023
1 parent 1bdafb3 commit 0f0ed1f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions command/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ impl WorkerResponse {
content: None,
}
}

pub fn is_failure(&self) -> bool {
self.status == ResponseStatus::Failure
}
}

impl fmt::Display for WorkerResponse {
Expand Down
16 changes: 13 additions & 3 deletions lib/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -982,14 +982,24 @@ impl Server {
};

let proxy_destinations = request.content.get_destinations();
let mut notify_response = None;
if proxy_destinations.to_http_proxy {
push_queue(self.http.borrow_mut().notify(request.clone()));
notify_response = Some(self.http.borrow_mut().notify(request.clone()));
}
if proxy_destinations.to_https_proxy {
push_queue(self.https.borrow_mut().notify(request.clone()));
let http_proxy_response = self.https.borrow_mut().notify(request.clone());
if http_proxy_response.is_failure() || notify_response.is_none() {
notify_response = Some(http_proxy_response);
}
}
if proxy_destinations.to_tcp_proxy {
push_queue(self.tcp.borrow_mut().notify(request.clone()));
let tcp_proxy_response = self.tcp.borrow_mut().notify(request.clone());
if tcp_proxy_response.is_failure() || notify_response.is_none() {
notify_response = Some(tcp_proxy_response);
}
}
if let Some(response) = notify_response {
push_queue(response);
}

match request.content.request_type {
Expand Down

0 comments on commit 0f0ed1f

Please sign in to comment.