Skip to content

Hyper 1 upgrade #749

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

Merged
merged 18 commits into from
Dec 18, 2023
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
16 changes: 16 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,19 @@ members = [
]

exclude = ["examples"]

[workspace.dependencies]
base64 = "0.21"
bytes = "1"
futures = "0.3"
futures-channel = "0.3"
futures-util = "0.3"
http = "1.0"
http-body = "1.0"
http-body-util = "0.1"
http-serde = "2.0"
hyper = "1.0"
hyper-util = "0.1.1"
pin-project-lite = "0.2"
tower = "0.4"
tower-service = "0.3"
5 changes: 0 additions & 5 deletions examples/basic-streaming-response/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
hyper = { version = "0.14", features = [
"http1",
"client",
"stream",
] }
lambda_runtime = { path = "../../lambda-runtime" }
tokio = { version = "1", features = ["macros"] }
tracing = { version = "0.1", features = ["log"] }
Expand Down
16 changes: 8 additions & 8 deletions examples/basic-streaming-response/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
use hyper::body::Body;
use lambda_runtime::{service_fn, Error, LambdaEvent, StreamResponse};
use lambda_runtime::{
service_fn,
streaming::{channel, Body, Response},
Error, LambdaEvent,
};
use serde_json::Value;
use std::{thread, time::Duration};

async fn func(_event: LambdaEvent<Value>) -> Result<StreamResponse<Body>, Error> {
async fn func(_event: LambdaEvent<Value>) -> Result<Response<Body>, Error> {
let messages = vec!["Hello", "world", "from", "Lambda!"];

let (mut tx, rx) = Body::channel();
let (mut tx, rx) = channel();

tokio::spawn(async move {
for message in messages.iter() {
Expand All @@ -15,10 +18,7 @@ async fn func(_event: LambdaEvent<Value>) -> Result<StreamResponse<Body>, Error>
}
});

Ok(StreamResponse {
metadata_prelude: Default::default(),
stream: rx,
})
Ok(Response::from(rx))
}

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion examples/http-axum-diesel-ssl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2021"
# and it will keep the alphabetic ordering for you.

[dependencies]
axum = "0.6.4"
axum = "0.7"
bb8 = "0.8.0"
diesel = "2.0.3"
diesel-async = { version = "0.2.1", features = ["postgres", "bb8"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/http-axum-diesel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2021"
# and it will keep the alphabetic ordering for you.

[dependencies]
axum = "0.6.4"
axum = "0.7"
bb8 = "0.8.0"
diesel = "2.0.3"
diesel-async = { version = "0.2.1", features = ["postgres", "bb8"] }
Expand Down
5 changes: 2 additions & 3 deletions examples/http-axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ edition = "2021"
# and it will keep the alphabetic ordering for you.

[dependencies]
axum = "0.7"
lambda_http = { path = "../../lambda-http" }
lambda_runtime = { path = "../../lambda-runtime" }
serde_json = "1.0"
tokio = { version = "1", features = ["macros"] }
tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt"] }

axum = "0.6.4"
serde_json = "1.0"
2 changes: 1 addition & 1 deletion examples/http-cors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ edition = "2021"
lambda_http = { path = "../../lambda-http" }
lambda_runtime = { path = "../../lambda-runtime" }
tokio = { version = "1", features = ["macros"] }
tower-http = { version = "0.3.3", features = ["cors"] }
tower-http = { version = "0.5", features = ["cors"] }
tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt"] }

Expand Down
2 changes: 1 addition & 1 deletion examples/http-tower-trace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ edition = "2021"
lambda_http = { path = "../../lambda-http" }
lambda_runtime = "0.5.1"
tokio = { version = "1", features = ["macros"] }
tower-http = { version = "0.3.4", features = ["trace"] }
tower-http = { version = "0.5", features = ["trace"] }
tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt"] }
20 changes: 10 additions & 10 deletions lambda-events/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ categories = ["api-bindings", "encoding", "web-programming"]
edition = "2021"

[dependencies]
base64 = "0.21"
http = { version = "0.2", optional = true }
http-body = { version = "0.4", optional = true }
http-serde = { version = "^1", optional = true }
serde = { version = "^1", features = ["derive"] }
serde_with = { version = "^3", features = ["json"], optional = true }
serde_json = "^1"
serde_dynamo = { version = "^4.1", optional = true }
bytes = { version = "1", features = ["serde"], optional = true }
base64 = { workspace = true }
bytes = { workspace = true, features = ["serde"], optional = true }
chrono = { version = "0.4.31", default-features = false, features = [
"clock",
"serde",
"std",
], optional = true }
flate2 = { version = "1.0.24", optional = true }
http = { workspace = true, optional = true }
http-body = { workspace = true, optional = true }
http-serde = { workspace = true, optional = true }
query_map = { version = "^0.7", features = [
"serde",
"url-query",
], optional = true }
flate2 = { version = "1.0.24", optional = true }
serde = { version = "^1", features = ["derive"] }
serde_with = { version = "^3", features = ["json"], optional = true }
serde_json = "^1"
serde_dynamo = { version = "^4.1", optional = true }

[features]
default = [
Expand Down
31 changes: 12 additions & 19 deletions lambda-events/src/encodings/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,25 +218,6 @@ impl HttpBody for Body {
type Data = Bytes;
type Error = super::Error;

fn poll_data(
self: Pin<&mut Self>,
_cx: &mut std::task::Context<'_>,
) -> Poll<Option<Result<Self::Data, Self::Error>>> {
let body = take(self.get_mut());
Poll::Ready(match body {
Body::Empty => None,
Body::Text(s) => Some(Ok(s.into())),
Body::Binary(b) => Some(Ok(b.into())),
})
}

fn poll_trailers(
self: Pin<&mut Self>,
_cx: &mut std::task::Context<'_>,
) -> Poll<Result<Option<http::HeaderMap>, Self::Error>> {
Poll::Ready(Ok(None))
}

fn is_end_stream(&self) -> bool {
matches!(self, Body::Empty)
}
Expand All @@ -248,6 +229,18 @@ impl HttpBody for Body {
Body::Binary(ref b) => SizeHint::with_exact(b.len() as u64),
}
}

fn poll_frame(
self: Pin<&mut Self>,
_cx: &mut std::task::Context<'_>,
) -> Poll<Option<Result<http_body::Frame<Self::Data>, Self::Error>>> {
let body = take(self.get_mut());
Poll::Ready(match body {
Body::Empty => None,
Body::Text(s) => Some(Ok(http_body::Frame::data(s.into()))),
Body::Binary(b) => Some(Ok(http_body::Frame::data(b.into()))),
})
}
}

#[cfg(test)]
Expand Down
2 changes: 0 additions & 2 deletions lambda-events/src/event/bedrock_agent_runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ pub struct Agent {

#[cfg(test)]
mod tests {
use serde_json;

#[test]
#[cfg(feature = "bedrock-agent-runtime")]
fn example_bedrock_agent__runtime_event() {
Expand Down
16 changes: 11 additions & 5 deletions lambda-extension/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,21 @@ readme = "README.md"

[dependencies]
async-stream = "0.3"
bytes = "1.0"
bytes = { workspace = true }
chrono = { version = "0.4", features = ["serde"] }
http = "0.2"
hyper = { version = "0.14.20", features = ["http1", "client", "server", "stream", "runtime"] }
http = { workspace = true }
http-body-util = { workspace = true }
hyper = { workspace = true, features = ["http1", "client", "server"] }
hyper-util = { workspace = true }
lambda_runtime_api_client = { version = "0.8", path = "../lambda-runtime-api-client" }
serde = { version = "1", features = ["derive"] }
serde_json = "^1"
tracing = { version = "0.1", features = ["log"] }
tokio = { version = "1.0", features = ["macros", "io-util", "sync", "rt-multi-thread"] }
tokio = { version = "1.0", features = [
"macros",
"io-util",
"sync",
"rt-multi-thread",
] }
tokio-stream = "0.1.2"
tower = { version = "0.4", features = ["make", "util"] }

2 changes: 1 addition & 1 deletion lambda-extension/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Error type that extensions may result in
pub type Error = lambda_runtime_api_client::Error;
pub type Error = lambda_runtime_api_client::BoxError;

/// Simple error that encapsulates human readable descriptions
#[derive(Clone, Debug, PartialEq, Eq)]
Expand Down
Loading