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

Do not resume on failure #158

Merged
merged 4 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 28 additions & 13 deletions src/filter/http_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ impl Filter {
}
}
}

fn process_next_op(&self) {
match self.operation_dispatcher.borrow_mut().next() {
Ok(some_op) => {
if some_op.is_none() {
// No more operations left in queue, resuming
self.resume_http_request();
}
}
Err(op_err) => {
// If desired, we could check the error status.
GrpcService::handle_error_on_grpc_response(op_err.failure_mode);
}
}
}
}

impl HttpContext for Filter {
Expand Down Expand Up @@ -134,21 +149,21 @@ impl Context for Filter {

match op_res {
Ok(operation) => {
if let Ok(result) = GrpcService::process_grpc_response(operation, resp_size) {
// add the response headers
self.response_headers_to_add.extend(result.response_headers);
// call the next op
match self.operation_dispatcher.borrow_mut().next() {
Ok(some_op) => {
if some_op.is_none() {
// No more operations left in queue, resuming
self.resume_http_request();
match GrpcService::process_grpc_response(Rc::clone(&operation), resp_size) {
Ok(result) => {
// add the response headers
self.response_headers_to_add.extend(result.response_headers);
// call the next op
self.process_next_op();
}
Err(_) => {
match operation.get_failure_mode() {
FailureMode::Deny => {}
FailureMode::Allow => {
// call the next op
self.process_next_op();
}
}
Err(op_err) => {
// If desired, we could check the error status.
GrpcService::handle_error_on_grpc_response(op_err.failure_mode);
}
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ impl GrpcService {
hostcalls::send_http_response(500, vec![], Some(b"Internal Server Error.\n"))
.expect("failed to send_http_response 500");
}
FailureMode::Allow => {
hostcalls::resume_http_request().expect("failed to resume_http_request")
}
FailureMode::Allow => {}
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions tests/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ fn it_auths() {
None,
Some(5000),
)
.returning(Some(42))
.returning(Ok(42))
.expect_log(
Some(LogLevel::Debug),
Some("#2 initiated gRPC call (id# 42)"),
Expand Down Expand Up @@ -362,7 +362,7 @@ fn it_denies() {
None,
Some(5000),
)
.returning(Some(42))
.returning(Ok(42))
.expect_log(
Some(LogLevel::Debug),
Some("#2 initiated gRPC call (id# 42)"),
Expand Down Expand Up @@ -563,7 +563,7 @@ fn it_does_not_fold_auth_actions() {
None,
Some(5000),
)
.returning(Some(42))
.returning(Ok(42))
.expect_log(
Some(LogLevel::Debug),
Some("#2 initiated gRPC call (id# 42)"),
Expand Down Expand Up @@ -661,7 +661,7 @@ fn it_does_not_fold_auth_actions() {
None,
Some(5000),
)
.returning(Some(42))
.returning(Ok(42))
.execute_and_expect(ReturnType::None)
.unwrap();

Expand Down
Loading
Loading