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

Hyper 1 upgrade #749

Merged
merged 18 commits into from
Dec 18, 2023
Merged

Hyper 1 upgrade #749

merged 18 commits into from
Dec 18, 2023

Conversation

calavera
Copy link
Contributor

@calavera calavera commented Dec 8, 2023

Issue #, if available:

fixes #737
fixes #738

Description of changes:

Hyper 1 has moved many things around, and unfortunately how to implement things now is not very clear.

  • Upgrade lambda_runtime
  • Upgrade lambda_http
  • Upgrade lambda-extension
  • Axum compatibility
  • Streaming

By submitting this pull request

  • I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • I confirm that I've made a best effort attempt to update all relevant documentation.

@awslabs awslabs deleted a comment from github-actions bot Dec 8, 2023
@calavera calavera changed the title Hyper1 upgrade Hyper 1 upgrade Dec 8, 2023
@awslabs awslabs deleted a comment from github-actions bot Dec 8, 2023
simbleau and others added 15 commits December 9, 2023 02:41
This makes tracking versions across packages easier.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Copy some of the utils that Axum created to support Hyper 1.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Signed-off-by: David Calavera <david.calavera@gmail.com>
Signed-off-by: David Calavera <david.calavera@gmail.com>
Signed-off-by: David Calavera <david.calavera@gmail.com>
Switch to use hyper::service::service_fn definitions.
Implement new Hyper's polling loop for http connections.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Signed-off-by: David Calavera <david.calavera@gmail.com>
Signed-off-by: David Calavera <david.calavera@gmail.com>
Signed-off-by: David Calavera <david.calavera@gmail.com>
Given the lack of a public implementation anymore, we don't have other choice but copying Hyper's private implementation.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Signed-off-by: David Calavera <david.calavera@gmail.com>
Signed-off-by: David Calavera <david.calavera@gmail.com>
Signed-off-by: David Calavera <david.calavera@gmail.com>
@calavera calavera marked this pull request as ready for review December 9, 2023 21:56
@calavera calavera mentioned this pull request Dec 9, 2023
2 tasks
This makes the streaming functionallity more concise.
It aliases other functionality to keep backwards compatibility.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Signed-off-by: David Calavera <david.calavera@gmail.com>
Signed-off-by: David Calavera <david.calavera@gmail.com>
Comment on lines 83 to 90
loop {
match futures_util::ready!(self.as_mut().project().body.poll_frame(cx)?) {
Some(frame) => match frame.into_data() {
Ok(data) => return Poll::Ready(Some(Ok(data))),
Err(_frame) => {}
},
None => return Poll::Ready(None),
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using loop, the following should also work.

        return match futures_util::ready!(self.as_mut().project().body.poll_frame(cx)?) {
            Some(frame) => match frame.into_data() {
                Ok(data) => Poll::Ready(Some(Ok(data))),
                Err(_frame) => Poll::Ready(None)
            },
            None => Poll::Ready(None),
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the code with this suggestion, thanks!

@bnusunny
Copy link
Contributor

Since we pull in 'Body' into this project, we probably need to use it across this project. It is re-exported in both lambda-runtime and lambda-http.

@calavera
Copy link
Contributor Author

Since we pull in 'Body' into this project, we probably need to use it across this project. It is re-exported in both lambda-runtime and lambda-http.

I understand that it can create confusion, that's why I re-exported the new body as streaming::Body. Both types are different, and I don't think it'd be possible to re-use the new type. The new type is pretty much what hyper::Body use to be, while lambda_http::Body represents the raw bytes that APIGW and ALB can send and receive through Lambda events.

@calavera calavera requested a review from bnusunny December 17, 2023 20:19
@calavera calavera merged commit 07430f1 into main Dec 18, 2023
12 checks passed
@calavera calavera deleted the hyper1_upgrade branch December 18, 2023 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Axum 7.x causes compilation errors. Upgrade to hyper/http 1.0
3 participants