From eed16d1c8f43c0df462e7ce50e1d8c8bb926d35b Mon Sep 17 00:00:00 2001 From: David Barsky Date: Fri, 17 Jul 2020 17:30:18 -0400 Subject: [PATCH 01/30] reorg --- Cargo.lock | 72 ---------- lambda/Cargo.toml | 3 - lambda/src/client.rs | 300 ++++++++++++++++------------------------ lambda/src/lib.rs | 18 +-- lambda/src/simulated.rs | 3 +- 5 files changed, 124 insertions(+), 272 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 49c98444..64842149 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -291,9 +291,6 @@ dependencies = [ "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing-error 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing-futures 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -578,14 +575,6 @@ dependencies = [ "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "sharded-slab" -version = "0.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "signal-hook-registry" version = "1.2.0" @@ -697,60 +686,6 @@ name = "tower-service" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "tracing" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing-attributes 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tracing-core" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tracing-error" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "tracing 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing-subscriber 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tracing-futures" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "pin-project 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tracing-subscriber" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "sharded-slab 0.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "try-lock" version = "0.2.2" @@ -909,7 +844,6 @@ dependencies = [ "checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" "checksum serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "eab8f15f15d6c41a154c1b128a22f2dfabe350ef53c40953d84e36155c91192b" "checksum serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" -"checksum sharded-slab 0.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "06d5a3f5166fb5b42a5439f2eee8b9de149e235961e3eb21c5808fc3ea17ff3e" "checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" @@ -921,12 +855,6 @@ dependencies = [ "checksum tokio-macros 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f4b1e7ed7d5d4c2af3d999904b0eebe76544897cdbfb2b9684bed2174ab20f7c" "checksum tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" "checksum tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" -"checksum tracing 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1721cc8cf7d770cc4257872507180f35a4797272f5962f24c806af9e7faf52ab" -"checksum tracing-attributes 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "7fbad39da2f9af1cae3016339ad7f2c7a9e870f12e8fd04c4fd7ef35b30c0d2b" -"checksum tracing-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0aa83a9a47081cd522c09c81b31aec2c9273424976f922ad61c053b58350b715" -"checksum tracing-error 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d7c0b83d4a500748fa5879461652b361edf5c9d51ede2a2ac03875ca185e24" -"checksum tracing-futures 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" -"checksum tracing-subscriber 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1d53c40489aa69c9aed21ff483f26886ca8403df33bdc2d2f87c60c1617826d2" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" diff --git a/lambda/Cargo.toml b/lambda/Cargo.toml index 7acf8cbd..f664182e 100644 --- a/lambda/Cargo.toml +++ b/lambda/Cargo.toml @@ -22,6 +22,3 @@ http = "0.2" lambda-attributes = { path = "../lambda-attributes", version = "0.1.0", optional = true} genawaiter = { version = "0.99", features = ["futures03"] } futures = "0.3" -tracing = "0.1.13" -tracing-futures = "0.2.3" -tracing-error = "0.1.2" diff --git a/lambda/src/client.rs b/lambda/src/client.rs index 64313ebf..2df9bd3b 100644 --- a/lambda/src/client.rs +++ b/lambda/src/client.rs @@ -1,65 +1,6 @@ -use crate::{ - requests::{IntoResponse, NextEventResponse}, - Error, -}; -use http::{ - uri::{PathAndQuery, Scheme}, - HeaderValue, Method, Request, Response, StatusCode, Uri, -}; -use hyper::{client::HttpConnector, server::conn::Http, service::service_fn, Body}; -use serde_json::json; -use std::convert::TryFrom; -use tokio::{ - io::{AsyncRead, AsyncWrite}, - select, - sync::oneshot, -}; -use tracing::{error, info, instrument}; - -#[instrument] -async fn hello(req: Request) -> Result, Error> { - Ok(Response::new(Body::from("hello"))) -} - -async fn handle_incoming(req: Request) -> Result, Error> { - let path: Vec<&str> = req - .uri() - .path_and_query() - .unwrap() - .as_str() - .split("/") - .collect::>(); - match &path[1..] { - ["2018-06-01", "runtime", "invocation", "next"] => next_event(&req).await, - ["2018-06-01", "runtime", "invocation", id, "response"] => complete_event(&req, id).await, - ["2018-06-01", "runtime", "invocation", id, "error"] => event_err(&req, id).await, - ["2018-06-01", "runtime", "init", "error"] => unimplemented!(), - _ => unimplemented!(), - } -} - -#[instrument(skip(io, rx))] -async fn handle(io: I, rx: oneshot::Receiver<()>) -> Result<(), hyper::error::Error> -where - I: AsyncRead + AsyncWrite + Unpin + 'static, -{ - let conn = Http::new().serve_connection(io, service_fn(handle_incoming)); - select! { - _ = rx => { - info!("Received cancelation signal"); - return Ok(()) - } - res = conn => { - match res { - Ok(()) => return Ok(()), - Err(e) => { - error!(message = "Got error serving connection", e = %e); - return Err(e); - } - } - } - } -} +use crate::Error; +use http::{uri::Scheme, Request, Response, Uri}; +use hyper::{client::HttpConnector, Body}; #[derive(Debug)] pub(crate) struct Client { @@ -105,83 +46,135 @@ where } } -async fn next_event(req: &Request) -> Result, Error> { - let path = "/2018-06-01/runtime/invocation/next"; - assert_eq!(req.method(), Method::GET); - assert_eq!(req.uri().path_and_query().unwrap(), &PathAndQuery::from_static(path)); - let body = json!({"message": "hello"}); - - let rsp = NextEventResponse { - request_id: "8476a536-e9f4-11e8-9739-2dfe598c3fcd", - deadline: 1_542_409_706_888, - arn: "arn:aws:lambda:us-east-2:123456789012:function:custom-runtime", - trace_id: "Root=1-5bef4de7-ad49b0e87f6ef6c87fc2e700;Parent=9a9197af755a6419", - body: serde_json::to_vec(&body)?, +#[cfg(test)] +mod endpoint_tests { + use crate::{ + requests::{ + EventCompletionRequest, EventErrorRequest, IntoRequest, IntoResponse, NextEventRequest, NextEventResponse, + }, + simulated::SimulatedConnector, + types::Diagnostic, + Error, + }; + use http::{ + uri::{PathAndQuery, Scheme}, + HeaderValue, Method, Request, Response, StatusCode, Uri, + }; + use hyper::{server::conn::Http, service::service_fn, Body}; + use serde_json::json; + use std::convert::TryFrom; + use tokio::{ + io::{AsyncRead, AsyncWrite}, + select, + sync::{self, oneshot}, }; - rsp.into_rsp().map_err(|e| e.into()) -} -async fn complete_event(req: &Request, id: &str) -> Result, Error> { - assert_eq!(Method::POST, req.method()); - let rsp = Response::builder() - .status(StatusCode::ACCEPTED) - .body(Body::empty()) - .expect("Unable to construct response"); + fn set_origin(base: Uri, req: Request) -> Result, Error> { + let (mut parts, body) = req.into_parts(); + let (scheme, authority) = { + let scheme = base.scheme().unwrap_or(&Scheme::HTTP); + let authority = base.authority().expect("Authority not found"); + (scheme, authority) + }; + let path = parts.uri.path_and_query().expect("PathAndQuery not found"); - let expected = format!("/2018-06-01/runtime/invocation/{}/response", id); - assert_eq!(expected, req.uri().path()); + let uri = Uri::builder() + .scheme(scheme.clone()) + .authority(authority.clone()) + .path_and_query(path.clone()) + .build() + .expect("Unable to build URI"); - Ok(rsp) -} + parts.uri = uri; + Ok(Request::from_parts(parts, body)) + } -async fn event_err(req: &Request, id: &str) -> Result, Error> { - let expected = format!("/2018-06-01/runtime/invocation/{}/error", id); - assert_eq!(expected, req.uri().path()); + #[cfg(test)] + async fn next_event(req: &Request) -> Result, Error> { + let path = "/2018-06-01/runtime/invocation/next"; + assert_eq!(req.method(), Method::GET); + assert_eq!(req.uri().path_and_query().unwrap(), &PathAndQuery::from_static(path)); + let body = json!({"message": "hello"}); + + let rsp = NextEventResponse { + request_id: "8476a536-e9f4-11e8-9739-2dfe598c3fcd", + deadline: 1_542_409_706_888, + arn: "arn:aws:lambda:us-east-2:123456789012:function:custom-runtime", + trace_id: "Root=1-5bef4de7-ad49b0e87f6ef6c87fc2e700;Parent=9a9197af755a6419", + body: serde_json::to_vec(&body)?, + }; + rsp.into_rsp().map_err(|e| e.into()) + } - assert_eq!(req.method(), Method::POST); - let header = "lambda-runtime-function-error-type"; - let expected = "unhandled"; - assert_eq!(req.headers()[header], HeaderValue::try_from(expected)?); + #[cfg(test)] + async fn complete_event(req: &Request, id: &str) -> Result, Error> { + assert_eq!(Method::POST, req.method()); + let rsp = Response::builder() + .status(StatusCode::ACCEPTED) + .body(Body::empty()) + .expect("Unable to construct response"); - let rsp = Response::builder().status(StatusCode::ACCEPTED).body(Body::empty())?; - Ok(rsp) -} + let expected = format!("/2018-06-01/runtime/invocation/{}/response", id); + assert_eq!(expected, req.uri().path()); -fn set_origin(base: Uri, req: Request) -> Result, Error> { - let (mut parts, body) = req.into_parts(); - let (scheme, authority) = { - let scheme = base.scheme().unwrap_or(&Scheme::HTTP); - let authority = base.authority().expect("Authority not found"); - (scheme, authority) - }; - let path = parts.uri.path_and_query().expect("PathAndQuery not found"); + Ok(rsp) + } - let uri = Uri::builder() - .scheme(scheme.clone()) - .authority(authority.clone()) - .path_and_query(path.clone()) - .build() - .expect("Unable to build URI"); + #[cfg(test)] + async fn event_err(req: &Request, id: &str) -> Result, Error> { + let expected = format!("/2018-06-01/runtime/invocation/{}/error", id); + assert_eq!(expected, req.uri().path()); - parts.uri = uri; - Ok(Request::from_parts(parts, body)) -} + assert_eq!(req.method(), Method::POST); + let header = "lambda-runtime-function-error-type"; + let expected = "unhandled"; + assert_eq!(req.headers()[header], HeaderValue::try_from(expected)?); -#[cfg(test)] -mod endpoint_tests { - use super::{handle, set_origin}; - use crate::{ - requests::{EventCompletionRequest, EventErrorRequest, IntoRequest, NextEventRequest}, - simulated::SimulatedConnector, - types::Diagnostic, - Error, - }; - use http::{HeaderValue, StatusCode, Uri}; - use std::convert::TryFrom; - use tokio::sync; + let rsp = Response::builder().status(StatusCode::ACCEPTED).body(Body::empty())?; + Ok(rsp) + } + + #[cfg(test)] + async fn handle_incoming(req: Request) -> Result, Error> { + let path: Vec<&str> = req + .uri() + .path_and_query() + .expect("PathAndQuery not found") + .as_str() + .split("/") + .collect::>(); + match &path[1..] { + ["2018-06-01", "runtime", "invocation", "next"] => next_event(&req).await, + ["2018-06-01", "runtime", "invocation", id, "response"] => complete_event(&req, id).await, + ["2018-06-01", "runtime", "invocation", id, "error"] => event_err(&req, id).await, + ["2018-06-01", "runtime", "init", "error"] => unimplemented!(), + _ => unimplemented!(), + } + } + + #[cfg(test)] + async fn handle(io: I, rx: oneshot::Receiver<()>) -> Result<(), hyper::error::Error> + where + I: AsyncRead + AsyncWrite + Unpin + 'static, + { + let conn = Http::new().serve_connection(io, service_fn(handle_incoming)); + select! { + _ = rx => { + return Ok(()) + } + res = conn => { + match res { + Ok(()) => return Ok(()), + Err(e) => { + return Err(e); + } + } + } + } + } #[tokio::test] - async fn next_event() -> Result<(), Error> { + async fn test_next_event() -> Result<(), Error> { let (client, server) = crate::simulated::chan(); let base = Uri::from_static("http://localhost:9001"); @@ -211,7 +204,7 @@ mod endpoint_tests { } #[tokio::test] - async fn ok_response() -> Result<(), Error> { + async fn test_ok_response() -> Result<(), Error> { let (client, server) = crate::simulated::chan(); let (tx, rx) = sync::oneshot::channel(); let base = Uri::from_static("http://localhost:9001"); @@ -243,7 +236,7 @@ mod endpoint_tests { } #[tokio::test] - async fn error_response() -> Result<(), Error> { + async fn test_error_response() -> Result<(), Error> { let (client, server) = crate::simulated::chan(); let (tx, rx) = sync::oneshot::channel(); let base = Uri::from_static("http://localhost:9001"); @@ -275,55 +268,4 @@ mod endpoint_tests { Err(_) => unreachable!("This branch shouldn't be reachable"), } } - - // #[tokio::test] - // async fn run_end_to_end() -> Result<(), Error> { - // use serde_json::Value; - - // let (client, server) = crate::simulated::chan(); - - // let (tx, rx) = sync::oneshot::channel(); - // let server = tokio::spawn(async move { handle(server, rx) }); - - // async fn handler(s: Value) -> Result { - // INVOCATION_CTX.with(|_ctx| {}); - // Ok(s) - // } - // let handler = handler_fn(handler); - // let client = tokio::spawn(async move { - // run_simulated(handler, &url).await?; - // Ok::<(), Error>(()) - // }); - // race!(client, server); - // Ok(()) - // } - - // #[tokio::test] - // async fn test_stream_handler() -> Result<(), Error> { - // let (client, server) = crate::simulated::chan(); - // let req = Request::builder() - // .method(Method::GET) - // .uri("http://httpbin.org") - // .body(Body::empty()) - // .expect("Can't build request"); - - // let conn = SimulatedConnector { inner: client }; - // let client = hyper::Client::builder().build(conn); - - // let (tx, rx) = sync::oneshot::channel(); - // let server = tokio::spawn(async { - // handle(server, rx).await.expect("Unable to handle request"); - // }); - - // let rsp = client.request(req).await.expect("Unable to send request"); - // assert_eq!(rsp.status(), http::StatusCode::OK); - - // // shutdown server - // tx.send(()).expect("Receiver has been dropped"); - // match server.await { - // Ok(_) => Ok(()), - // Err(e) if e.is_panic() => return Err::<(), anyhow::Error>(e.into()), - // Err(_) => unreachable!("This branch shouldn't be reachable"), - // } - // } } diff --git a/lambda/src/lib.rs b/lambda/src/lib.rs index 4d6b3839..6eedcb2a 100644 --- a/lambda/src/lib.rs +++ b/lambda/src/lib.rs @@ -47,6 +47,7 @@ use std::{ mod client; mod requests; +#[cfg(test)] mod simulated; /// Types available to a Lambda function. mod types; @@ -161,23 +162,6 @@ where Ok(()) } -/// Runs the lambda function almost entirely in-memory. This is meant for testing. -pub async fn run_simulated(handler: F, url: &str) -> Result<(), Error> -where - F: Handler, - >::Error: fmt::Debug, - A: for<'de> Deserialize<'de>, - B: Serialize, -{ - let mut handler = handler; - let uri = url.try_into().expect("Unable to convert to URL"); - let client = Client::with(uri, hyper::Client::new()); - let incoming = incoming(&client).take(1); - run_inner(&client, incoming, &mut handler).await?; - - Ok(()) -} - fn incoming(client: &Client) -> impl Stream, Error>> + '_ { gen!({ loop { diff --git a/lambda/src/simulated.rs b/lambda/src/simulated.rs index b59f0754..87e66743 100644 --- a/lambda/src/simulated.rs +++ b/lambda/src/simulated.rs @@ -12,7 +12,7 @@ use std::{ use tokio::io::{AsyncRead, AsyncWrite}; use tower_service::Service; -/// Creates a pair of AsyncReadWrite data streams, where the write end of each member of the pair +/// Creates a pair of `AsyncRead/AsyncWrite data streams, where the write end of each member of the pair /// is the read end of the other member of the pair. This allows us to emulate the behavior of a TcpStream /// but in-memory, deterministically, and with full control over failure injection. pub(crate) fn chan() -> (SimStream, SimStream) { @@ -104,6 +104,7 @@ pub struct BufferState { } impl BufferState { + /// Creates a new `BufferState`. fn new() -> Self { BufferState { buffer: VecDeque::new(), From 64cd7dff02846a987426b15d560127f510704bd9 Mon Sep 17 00:00:00 2001 From: Lucio Franco Date: Fri, 17 Jul 2020 17:37:23 -0400 Subject: [PATCH 02/30] Replace `genawaiter` with `async-stream` (#240) --- Cargo.lock | 97 +++++++++++------------------------------------ lambda/Cargo.toml | 2 +- lambda/src/lib.rs | 13 ++++--- 3 files changed, 30 insertions(+), 82 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 64842149..9d742fc0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,6 +5,25 @@ name = "arc-swap" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "async-stream" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "async-stream-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "async-stream-impl" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "autocfg" version = "1.0.0" @@ -136,34 +155,6 @@ dependencies = [ "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "genawaiter" -version = "0.99.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "genawaiter-macro 0.99.1 (registry+https://github.com/rust-lang/crates.io-index)", - "genawaiter-proc-macro 0.99.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "genawaiter-macro" -version = "0.99.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "genawaiter-proc-macro" -version = "0.99.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro-error 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "h2" version = "0.2.1" @@ -281,9 +272,9 @@ dependencies = [ name = "lambda" version = "0.1.0" dependencies = [ + "async-stream 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "genawaiter 0.99.1 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "lambda-attributes 0.1.0", @@ -463,30 +454,6 @@ name = "pin-utils" version = "0.1.0-alpha.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "proc-macro-error" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro-error-attr 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "proc-macro-error-attr" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", - "syn-mid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "proc-macro-hack" version = "0.5.11" @@ -615,16 +582,6 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "syn-mid" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "time" version = "0.1.42" @@ -727,11 +684,6 @@ dependencies = [ "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "version_check" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "want" version = "0.3.0" @@ -781,6 +733,8 @@ dependencies = [ [metadata] "checksum arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d7b8a9123b8027467bce0099fe556c628a53c8d83df0507084c31e9ba2e39aff" +"checksum async-stream 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "22068c0c19514942eefcfd4daf8976ef1aad84e61539f95cd200c35202f80af5" +"checksum async-stream-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "25f9db3b38af870bf7e5cc649167533b493928e50744e2c30ae350230b414670" "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" "checksum base64 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "53d1ccbaf7d9ec9537465a97bf19edc1a4e158ecb49fc16178202238c569cc42" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" @@ -799,9 +753,6 @@ dependencies = [ "checksum futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "171be33efae63c2d59e6dbba34186fe0d6394fb378069a76dfd80fdcffd43c16" "checksum futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9" "checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" -"checksum genawaiter 0.99.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c86bd0361bcbde39b13475e6e36cb24c329964aa2611be285289d1e4b751c1a0" -"checksum genawaiter-macro 0.99.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b32dfe1fdfc0bbde1f22a5da25355514b5e450c33a6af6770884c8750aedfbc" -"checksum genawaiter-proc-macro 0.99.1 (registry+https://github.com/rust-lang/crates.io-index)" = "784f84eebc366e15251c4a8c3acee82a6a6f427949776ecb88377362a9621738" "checksum h2 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9433d71e471c1736fd5a61b671fc0b148d7a2992f666c958d03cd8feb3b88d1" "checksum hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772" "checksum http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b708cc7f06493459026f53b9a61a7a121a5d1ec6238dee58ea4941132b30156b" @@ -831,8 +782,6 @@ dependencies = [ "checksum pin-project-internal 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "385322a45f2ecf3410c68d2a549a4a2685e8051d0f278e39743ff4e451cb9b3f" "checksum pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae" "checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" -"checksum proc-macro-error 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7" -"checksum proc-macro-error-attr 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69de" "checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" "checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" @@ -849,7 +798,6 @@ dependencies = [ "checksum smallvec 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" "checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" "checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" -"checksum syn-mid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8fdd17989496f49cdc57978c96f0c9fe5e4a58a8bddc6813c449a4624f6a030b" "checksum tokio-macros 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f4b1e7ed7d5d4c2af3d999904b0eebe76544897cdbfb2b9684bed2174ab20f7c" @@ -861,7 +809,6 @@ dependencies = [ "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" -"checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" "checksum want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" diff --git a/lambda/Cargo.toml b/lambda/Cargo.toml index f664182e..e7e3d4ca 100644 --- a/lambda/Cargo.toml +++ b/lambda/Cargo.toml @@ -20,5 +20,5 @@ tower-service = "0.3" bytes = "0.5" http = "0.2" lambda-attributes = { path = "../lambda-attributes", version = "0.1.0", optional = true} -genawaiter = { version = "0.99", features = ["futures03"] } +async-stream = "0.2" futures = "0.3" diff --git a/lambda/src/lib.rs b/lambda/src/lib.rs index 6eedcb2a..f955313d 100644 --- a/lambda/src/lib.rs +++ b/lambda/src/lib.rs @@ -36,7 +36,6 @@ pub use crate::types::Context; use client::Client; use futures::stream::{Stream, StreamExt}; -use genawaiter::{sync::gen, yield_}; pub use lambda_attributes::lambda; use serde::{Deserialize, Serialize}; use std::{ @@ -163,17 +162,18 @@ where } fn incoming(client: &Client) -> impl Stream, Error>> + '_ { - gen!({ + async_stream::stream! { loop { let req = NextEventRequest.into_req().expect("Unable to construct request"); - yield_!(client.call(req).await) + let res = client.call(req).await; + yield res; } - }) + } } async fn run_inner( client: &Client, - incoming: impl Stream, Error>> + Unpin, + incoming: impl Stream, Error>>, handler: &mut F, ) -> Result<(), Error> where @@ -182,7 +182,8 @@ where A: for<'de> Deserialize<'de>, B: Serialize, { - let mut incoming = incoming; + tokio::pin!(incoming); + while let Some(event) = incoming.next().await { let event = event?; let (parts, body) = event.into_parts(); From 116368221a5d64e0063dd7cb4f2df8788fc7243b Mon Sep 17 00:00:00 2001 From: David Barsky Date: Fri, 17 Jul 2020 17:51:08 -0400 Subject: [PATCH 03/30] don't depend on serde_derive directly --- Cargo.lock | 1 - lambda-http/Cargo.toml | 3 +-- lambda-http/src/ext.rs | 7 +++---- lambda-http/src/request.rs | 11 ++++++----- lambda-http/src/response.rs | 6 ++---- lambda-http/src/strmap.rs | 11 +++++------ lambda/src/lib.rs | 1 - 7 files changed, 17 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d742fc0..771965ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -304,7 +304,6 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/lambda-http/Cargo.toml b/lambda-http/Cargo.toml index 125b1714..e969ef7b 100644 --- a/lambda-http/Cargo.toml +++ b/lambda-http/Cargo.toml @@ -20,8 +20,7 @@ base64 = "0.12" http = "0.2" lambda = { path = "../lambda", version = "0.1" } lambda-attributes = { path = "../lambda-attributes", version = "0.1" } -serde = "^1" -serde_derive = "^1" +serde = { version = "^1", features = ["derive"] } serde_json = "^1" serde_urlencoded = "0.6" diff --git a/lambda-http/src/ext.rs b/lambda-http/src/ext.rs index dd08ae73..64efa766 100644 --- a/lambda-http/src/ext.rs +++ b/lambda-http/src/ext.rs @@ -1,10 +1,9 @@ //! Extension methods for `http::Request` types +use crate::{request::RequestContext, strmap::StrMap, Body}; use serde::{de::value::Error as SerdeError, Deserialize}; use std::{error::Error, fmt}; -use crate::{request::RequestContext, strmap::StrMap, Body}; - /// ALB/API gateway pre-parsed http query string parameters pub(crate) struct QueryStringParameters(pub(crate) StrMap); @@ -68,7 +67,7 @@ impl Error for PayloadError { /// /// ```rust,no_run /// use lambda_http::{handler, lambda::{self, Context}, Body, IntoResponse, Request, Response, RequestExt}; -/// use serde_derive::Deserialize; +/// use serde::Deserialize; /// /// type Error = Box; /// @@ -255,7 +254,7 @@ impl RequestExt for http::Request { #[cfg(test)] mod tests { use crate::{Body, Request, RequestExt}; - use serde_derive::Deserialize; + use serde::Deserialize; #[test] fn requests_can_mock_query_string_parameters_ext() { diff --git a/lambda-http/src/request.rs b/lambda-http/src/request.rs index 852e1e04..fd4e52d9 100644 --- a/lambda-http/src/request.rs +++ b/lambda-http/src/request.rs @@ -3,16 +3,17 @@ //! Typically these are exposed via the `request_context` //! request extension method provided by [lambda_http::RequestExt](../trait.RequestExt.html) //! -use serde::de::{Deserialize, Deserializer, Error as DeError, MapAccess, Visitor}; -use serde_derive::Deserialize; -use serde_json::{error::Error as JsonError, Value}; -use std::{borrow::Cow, collections::HashMap, fmt, io::Read, mem}; - use crate::{ body::Body, ext::{PathParameters, QueryStringParameters, StageVariables}, strmap::StrMap, }; +use serde::{ + de::{Deserializer, Error as DeError, MapAccess, Visitor}, + Deserialize, +}; +use serde_json::{error::Error as JsonError, Value}; +use std::{borrow::Cow, collections::HashMap, fmt, io::Read, mem}; /// Internal representation of an Lambda http event from /// ALB, API Gateway REST and HTTP API proxy event perspectives diff --git a/lambda-http/src/response.rs b/lambda-http/src/response.rs index 61406426..bdeee5c1 100644 --- a/lambda-http/src/response.rs +++ b/lambda-http/src/response.rs @@ -1,16 +1,14 @@ //! Response types +use crate::body::Body; use http::{ header::{HeaderMap, HeaderValue, CONTENT_TYPE}, Response, }; use serde::{ ser::{Error as SerError, SerializeMap}, - Serializer, + Serialize, Serializer, }; -use serde_derive::Serialize; - -use crate::body::Body; /// Representation of API Gateway response #[doc(hidden)] diff --git a/lambda-http/src/strmap.rs b/lambda-http/src/strmap.rs index 10801733..281a1101 100644 --- a/lambda-http/src/strmap.rs +++ b/lambda-http/src/strmap.rs @@ -1,14 +1,13 @@ +use serde::{ + de::{MapAccess, Visitor}, + Deserialize, Deserializer, +}; use std::{ collections::{hash_map::Keys, HashMap}, fmt, sync::Arc, }; -use serde::{ - de::{MapAccess, Visitor}, - Deserialize, Deserializer, -}; - /// A read-only view into a map of string data which may contain multiple values /// /// Internally data is always represented as many valued @@ -76,7 +75,7 @@ impl<'a> Iterator for StrMapIter<'a> { /// internal type used when deserializing StrMaps from /// potentially one or many valued maps -#[derive(serde_derive::Deserialize)] +#[derive(Deserialize)] #[serde(untagged)] enum OneOrMany { One(String), diff --git a/lambda/src/lib.rs b/lambda/src/lib.rs index f955313d..51af6434 100644 --- a/lambda/src/lib.rs +++ b/lambda/src/lib.rs @@ -183,7 +183,6 @@ where B: Serialize, { tokio::pin!(incoming); - while let Some(event) = incoming.next().await { let event = event?; let (parts, body) = event.into_parts(); From d4a937672bfd7ba0423267877f6f956a9a637d24 Mon Sep 17 00:00:00 2001 From: David Barsky Date: Fri, 17 Jul 2020 17:57:45 -0400 Subject: [PATCH 04/30] Add Cargo.lock to gitignore; whoops. --- .gitignore | 1 + Cargo.lock | 817 ---------------------------------------- lambda/src/simulated.rs | 2 +- 3 files changed, 2 insertions(+), 818 deletions(-) delete mode 100644 Cargo.lock diff --git a/.gitignore b/.gitignore index 911cf87c..94f3d847 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /target /.cargo lambda-runtime/libtest.rmeta +Cargo.lock # Built AWS Lambda zipfile lambda.zip diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 771965ff..00000000 --- a/Cargo.lock +++ /dev/null @@ -1,817 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "arc-swap" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "async-stream" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "async-stream-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "async-stream-impl" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "autocfg" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "base64" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bytes" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "dtoa" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "fnv" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-channel" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures-executor" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-io" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures-macro" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-sink" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures-task" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures-util" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "h2" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "hermit-abi" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "http" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "http-body" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "httparse" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "hyper" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "h2 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "http-body 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "idna" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "indexmap" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "itoa" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lambda" -version = "0.1.0" -dependencies = [ - "async-stream 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lambda-attributes 0.1.0", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lambda-attributes" -version = "0.1.0" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lambda_http" -version = "0.2.0-beta.1" -dependencies = [ - "base64 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lambda 0.1.0", - "lambda-attributes 0.1.0", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.66" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "log" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "maplit" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "matches" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "memchr" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "mio" -version = "0.6.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "mio-named-pipes" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", - "miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "mio-uds" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "miow" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "miow" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "net2" -version = "0.2.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "num_cpus" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "percent-encoding" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "pin-project" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "pin-project-internal 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pin-project-internal" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pin-project-lite" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "pin-utils" -version = "0.1.0-alpha.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "proc-macro-hack" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "proc-macro-nested" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "proc-macro2" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quote" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "redox_syscall" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ryu" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde" -version = "1.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_derive" -version = "1.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_json" -version = "1.0.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_urlencoded" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "dtoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "signal-hook-registry" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "smallvec" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "socket2" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syn" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "time" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-named-pipes 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-macros 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-macros" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-util" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tower-service" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "try-lock" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unicode-bidi" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-normalization" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "smallvec 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unicode-xid" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "url" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "want" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[metadata] -"checksum arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d7b8a9123b8027467bce0099fe556c628a53c8d83df0507084c31e9ba2e39aff" -"checksum async-stream 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "22068c0c19514942eefcfd4daf8976ef1aad84e61539f95cd200c35202f80af5" -"checksum async-stream-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "25f9db3b38af870bf7e5cc649167533b493928e50744e2c30ae350230b414670" -"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" -"checksum base64 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "53d1ccbaf7d9ec9537465a97bf19edc1a4e158ecb49fc16178202238c569cc42" -"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -"checksum bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" -"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum dtoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4358a9e11b9a09cf52383b451b49a169e8d797b68aa02301ff586d70d9661ea3" -"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" -"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6f16056ecbb57525ff698bb955162d0cd03bee84e6241c27ff75c08d8ca5987" -"checksum futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fcae98ca17d102fd8a3603727b9259fcf7fa4239b603d2142926189bc8999b86" -"checksum futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866" -"checksum futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e274736563f686a837a0568b478bdabfeaec2dca794b5649b04e2fe1627c231" -"checksum futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e676577d229e70952ab25f3945795ba5b16d63ca794ca9d2c860e5595d20b5ff" -"checksum futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "52e7c56c15537adb4f76d0b7a76ad131cb4d2f4f32d3b0bcabcbe1c7c5e87764" -"checksum futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "171be33efae63c2d59e6dbba34186fe0d6394fb378069a76dfd80fdcffd43c16" -"checksum futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9" -"checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" -"checksum h2 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9433d71e471c1736fd5a61b671fc0b148d7a2992f666c958d03cd8feb3b88d1" -"checksum hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772" -"checksum http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b708cc7f06493459026f53b9a61a7a121a5d1ec6238dee58ea4941132b30156b" -"checksum http-body 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" -"checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" -"checksum hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8bf49cfb32edee45d890537d9057d1b02ed55f53b7b6a30bae83a38c9231749e" -"checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" -"checksum indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b54058f0a6ff80b6803da8faf8997cde53872b38f4023728f6830b06cd3c0dc" -"checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -"checksum itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" -"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" -"checksum memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" -"checksum mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" -"checksum mio-named-pipes 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f5e374eff525ce1c5b7687c4cef63943e7686524a387933ad27ca7ec43779cb3" -"checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" -"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -"checksum miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "396aa0f2003d7df8395cb93e09871561ccc3e785f0acb369170e8cc74ddf9226" -"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" -"checksum num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" -"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" -"checksum pin-project 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7804a463a8d9572f13453c516a5faea534a2403d7ced2f0c7e100eeff072772c" -"checksum pin-project-internal 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "385322a45f2ecf3410c68d2a549a4a2685e8051d0f278e39743ff4e451cb9b3f" -"checksum pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae" -"checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" -"checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" -"checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" -"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" -"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" -"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" -"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" -"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" -"checksum serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "eab8f15f15d6c41a154c1b128a22f2dfabe350ef53c40953d84e36155c91192b" -"checksum serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" -"checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" -"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -"checksum smallvec 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" -"checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" -"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" -"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -"checksum tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8fdd17989496f49cdc57978c96f0c9fe5e4a58a8bddc6813c449a4624f6a030b" -"checksum tokio-macros 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f4b1e7ed7d5d4c2af3d999904b0eebe76544897cdbfb2b9684bed2174ab20f7c" -"checksum tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" -"checksum tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" -"checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" -"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -"checksum unicode-normalization 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" -"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -"checksum url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" -"checksum want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" diff --git a/lambda/src/simulated.rs b/lambda/src/simulated.rs index 87e66743..ea41e2d5 100644 --- a/lambda/src/simulated.rs +++ b/lambda/src/simulated.rs @@ -12,7 +12,7 @@ use std::{ use tokio::io::{AsyncRead, AsyncWrite}; use tower_service::Service; -/// Creates a pair of `AsyncRead/AsyncWrite data streams, where the write end of each member of the pair +/// Creates a pair of `AsyncRead`/`AsyncWrite` data streams, where the write end of each member of the pair /// is the read end of the other member of the pair. This allows us to emulate the behavior of a TcpStream /// but in-memory, deterministically, and with full control over failure injection. pub(crate) fn chan() -> (SimStream, SimStream) { From c0d34189a2d85bfcb4ceecd96639da00f95294f5 Mon Sep 17 00:00:00 2001 From: David Barsky Date: Sun, 19 Jul 2020 12:11:52 -0400 Subject: [PATCH 05/30] Cleanup docs; handle panics in lambda functions correctly. --- lambda/Cargo.toml | 1 - lambda/src/lib.rs | 98 +++++++++++++++++++++++++++++++---------------- 2 files changed, 64 insertions(+), 35 deletions(-) diff --git a/lambda/Cargo.toml b/lambda/Cargo.toml index e7e3d4ca..e40e796f 100644 --- a/lambda/Cargo.toml +++ b/lambda/Cargo.toml @@ -21,4 +21,3 @@ bytes = "0.5" http = "0.2" lambda-attributes = { path = "../lambda-attributes", version = "0.1.0", optional = true} async-stream = "0.2" -futures = "0.3" diff --git a/lambda/src/lib.rs b/lambda/src/lib.rs index 51af6434..721755c9 100644 --- a/lambda/src/lib.rs +++ b/lambda/src/lib.rs @@ -4,14 +4,14 @@ //! The official Rust runtime for AWS Lambda. //! //! There are two mechanisms available for defining a Lambda function: -//! 1. The `#[lambda]` attribute, which generates the boilerplate to +//! 1. The `lambda` attribute maco, which generates the boilerplate to //! to launch and run a Lambda function. //! -//! The `#[lambda]` attribute _must_ be placed on an asynchronous main function. +//! The [`#[lambda]`] attribute _must_ be placed on an asynchronous main function. //! However, as asynchronous main functions are not legal valid Rust //! this means that the main function must also be decorated using a -//! `#[tokio::main]` attribute macro. This is available from -//! the [tokio](https://github.com/tokio-rs/tokio) crate. +//! [`#[tokio::main]`] attribute macro. This is available from +//! the [Tokio] crate. //! //! 2. A type that conforms to the [`Handler`] trait. This type can then be passed //! to the the `lambda::run` function, which launches and runs the Lambda runtime. @@ -33,16 +33,23 @@ //! Ok(event) //! } //! ``` +//! +//! [`Handler`]: trait.Handler.html +//! [`lambda::Context`]: struct.Context.html +//! [`lambda`]: attr.lambda.html +//! [`#[tokio::main]`]: https://docs.rs/tokio/0.2.21/tokio/attr.main.html +//! [Tokio]: https://docs.rs/tokio/ pub use crate::types::Context; use client::Client; -use futures::stream::{Stream, StreamExt}; pub use lambda_attributes::lambda; use serde::{Deserialize, Serialize}; use std::{ convert::{TryFrom, TryInto}, env, fmt, future::Future, + sync::Arc, }; +use tokio::stream::{Stream, StreamExt}; mod client; mod requests; @@ -89,22 +96,26 @@ impl Config { } } -/// A trait describing an asynchronous function `A` to `B. +/// A trait describing an asynchronous function `A` to `B`. pub trait Handler { /// Errors returned by this handler. type Error; - /// The future response value of this handler. + /// Response of this handler. type Fut: Future>; - /// Process the incoming event and `Context` then return the response asynchronously. - fn call(&mut self, event: A, context: Context) -> Self::Fut; + /// Handle the incoming event. + fn call(&self, event: A, context: Context) -> Self::Fut; } -/// Returns a new `HandlerFn` with the given closure. +/// Returns a new [`HandlerFn`] with the given closure. +/// +/// [`HandlerFn`]: struct.HandlerFn.html pub fn handler_fn(f: F) -> HandlerFn { HandlerFn { f } } -/// A `Handler` implemented by a closure. +/// A [`Handler`] implemented by a closure. +/// +/// [`Handler`]: trait.Handler.html #[derive(Clone, Debug)] pub struct HandlerFn { f: F, @@ -113,12 +124,12 @@ pub struct HandlerFn { impl Handler for HandlerFn where F: Fn(A, Context) -> Fut, - Fut: Future> + Send, - Error: Into + fmt::Debug, + Fut: Future> + Send + Sync, + Error: Into> + fmt::Debug, { type Error = Error; type Fut = Fut; - fn call(&mut self, req: A, ctx: Context) -> Self::Fut { + fn call(&self, req: A, ctx: Context) -> Self::Fut { (self.f)(req, ctx) } } @@ -146,17 +157,17 @@ where /// ``` pub async fn run(handler: F) -> Result<(), Error> where - F: Handler, - >::Error: fmt::Debug, - A: for<'de> Deserialize<'de>, - B: Serialize, + F: Handler + Send + Sync + 'static, + >::Fut: Future>::Error>> + Send + Sync + 'static, + >::Error: fmt::Debug + Send + Sync + 'static, + A: for<'de> Deserialize<'de> + Send + Sync + 'static, + B: Serialize + Send + Sync + 'static, { - let mut handler = handler; let config = Config::from_env()?; let uri = config.endpoint.try_into().expect("Unable to convert to URL"); let client = Client::with(uri, hyper::Client::new()); let incoming = incoming(&client); - run_inner(&client, incoming, &mut handler).await?; + run_inner(&client, incoming, handler).await?; Ok(()) } @@ -174,14 +185,16 @@ fn incoming(client: &Client) -> impl Stream( client: &Client, incoming: impl Stream, Error>>, - handler: &mut F, + handler: F, ) -> Result<(), Error> where - F: Handler, - >::Error: fmt::Debug, - A: for<'de> Deserialize<'de>, - B: Serialize, + F: Handler + Send + Sync + 'static, + >::Fut: Future>::Error>> + Send + Sync + 'static, + >::Error: fmt::Debug + Send + Sync + 'static, + A: for<'de> Deserialize<'de> + Send + Sync + 'static, + B: Serialize + Send + Sync + 'static, { + let handler = Arc::new(handler); tokio::pin!(incoming); while let Some(event) = incoming.next().await { let event = event?; @@ -191,21 +204,38 @@ where let body = hyper::body::to_bytes(body).await?; let body = serde_json::from_slice(&body)?; + let handler = Arc::clone(&handler); let request_id = &ctx.request_id.clone(); - let f = handler.call(body, ctx); - - let req = match f.await { - Ok(res) => EventCompletionRequest { request_id, body: res }.into_req()?, - Err(e) => EventErrorRequest { + let task = tokio::spawn(async move { handler.call(body, ctx) }); + + let req = match task.await { + Ok(response) => match response.await { + Ok(response) => EventCompletionRequest { + request_id, + body: response, + } + .into_req(), + Err(err) => EventErrorRequest { + request_id, + diagnostic: Diagnostic { + error_type: type_name_of_val(&err).to_owned(), + error_message: format!("{:?}", err), + }, + } + .into_req(), + }, + Err(err) if err.is_panic() => EventErrorRequest { request_id, diagnostic: Diagnostic { - error_message: format!("{:?}", e), - error_type: type_name_of_val(e).to_owned(), + error_type: type_name_of_val(&err).to_owned(), + error_message: "Lambda panicked!".to_owned(), }, } - .into_req()?, + .into_req(), + Err(_) => unreachable!("tokio::task should not be canceled"), }; - client.call(req).await?; + let req = req?; + client.call(req).await.expect("Unable to send response to Runtime APIs"); } Ok(()) From e2b22e3e4cf50786ed30fb93a3cb790f49c02700 Mon Sep 17 00:00:00 2001 From: David Barsky Date: Sun, 19 Jul 2020 15:48:23 -0400 Subject: [PATCH 06/30] Create a reusable runtime struct + builder --- lambda-http/src/lib.rs | 12 +- lambda/Cargo.toml | 8 +- lambda/src/client.rs | 111 ++++++++++-------- lambda/src/lib.rs | 242 +++++++++++++++++++++++++++------------- lambda/src/requests.rs | 2 +- lambda/src/simulated.rs | 8 +- 6 files changed, 247 insertions(+), 136 deletions(-) diff --git a/lambda-http/src/lib.rs b/lambda-http/src/lib.rs index f26fa351..cf7e3eff 100644 --- a/lambda-http/src/lib.rs +++ b/lambda-http/src/lib.rs @@ -124,7 +124,7 @@ pub trait Handler: Sized { /// The type of Future this Handler will return type Fut: Future> + 'static; /// Function used to execute handler behavior - fn call(&mut self, event: Request, context: Context) -> Self::Fut; + fn call(&self, event: Request, context: Context) -> Self::Fut; } /// Adapts a [`Handler`](trait.Handler.html) to the `lambda::run` interface @@ -135,15 +135,15 @@ pub fn handler(handler: H) -> Adapter { /// An implementation of `Handler` for a given closure return a `Future` representing the computed response impl Handler for F where - F: FnMut(Request, Context) -> Fut, + F: Fn(Request, Context) -> Fut, R: IntoResponse, Fut: Future> + Send + 'static, { type Response = R; type Error = Error; type Fut = Fut; - fn call(&mut self, event: Request, context: Context) -> Self::Fut { - (*self)(event, context) + fn call(&self, event: Request, context: Context) -> Self::Fut { + (self)(event, context) } } @@ -183,7 +183,7 @@ impl Handler for Adapter { type Response = H::Response; type Error = H::Error; type Fut = H::Fut; - fn call(&mut self, event: Request, context: Context) -> Self::Fut { + fn call(&self, event: Request, context: Context) -> Self::Fut { self.handler.call(event, context) } } @@ -191,7 +191,7 @@ impl Handler for Adapter { impl LambdaHandler, LambdaResponse> for Adapter { type Error = H::Error; type Fut = TransformResponse; - fn call(&mut self, event: LambdaRequest<'_>, context: Context) -> Self::Fut { + fn call(&self, event: LambdaRequest<'_>, context: Context) -> Self::Fut { let is_alb = event.is_alb(); let fut = Box::pin(self.handler.call(event.into(), context)); TransformResponse { is_alb, fut } diff --git a/lambda/Cargo.toml b/lambda/Cargo.toml index e40e796f..60fb5b47 100644 --- a/lambda/Cargo.toml +++ b/lambda/Cargo.toml @@ -2,8 +2,11 @@ name = "lambda" version = "0.1.0" authors = ["David Barsky "] -description = "AWS Lambda Runtime." +description = "AWS Lambda Runtime" edition = "2018" +license = "Apache License 2.0" +repository = "https://github.com/awslabs/aws-lambda-rust-runtime" +readme = "../README.md" [features] # no features by default @@ -21,3 +24,6 @@ bytes = "0.5" http = "0.2" lambda-attributes = { path = "../lambda-attributes", version = "0.1.0", optional = true} async-stream = "0.2" + +[dev-dependencies] +once_cell = "1.4.0" diff --git a/lambda/src/client.rs b/lambda/src/client.rs index 2df9bd3b..88de0037 100644 --- a/lambda/src/client.rs +++ b/lambda/src/client.rs @@ -1,18 +1,20 @@ use crate::Error; use http::{uri::Scheme, Request, Response, Uri}; use hyper::{client::HttpConnector, Body}; +use std::fmt::Debug; #[derive(Debug)] pub(crate) struct Client { - base: Uri, - client: hyper::Client, + pub(crate) base: Uri, + pub(crate) client: hyper::Client, } impl Client where C: hyper::client::connect::Connect + Sync + Send + Clone + 'static, { - pub fn with(base: Uri, client: hyper::Client) -> Self { + pub fn with(base: Uri, connector: C) -> Self { + let client = hyper::Client::builder().build(connector); Self { base, client } } @@ -39,7 +41,6 @@ where pub(crate) async fn call(&self, req: Request) -> Result, Error> { let req = self.set_origin(req)?; let (parts, body) = req.into_parts(); - let body = Body::from(body); let req = Request::from_parts(parts, body); let response = self.client.request(req).await?; Ok(response) @@ -49,46 +50,26 @@ where #[cfg(test)] mod endpoint_tests { use crate::{ + client::Client, + incoming, requests::{ EventCompletionRequest, EventErrorRequest, IntoRequest, IntoResponse, NextEventRequest, NextEventResponse, }, - simulated::SimulatedConnector, + simulated, types::Diagnostic, - Error, - }; - use http::{ - uri::{PathAndQuery, Scheme}, - HeaderValue, Method, Request, Response, StatusCode, Uri, + Error, Runtime, }; + use http::{uri::PathAndQuery, HeaderValue, Method, Request, Response, StatusCode, Uri}; use hyper::{server::conn::Http, service::service_fn, Body}; use serde_json::json; use std::convert::TryFrom; + use tokio::stream::StreamExt; use tokio::{ io::{AsyncRead, AsyncWrite}, select, sync::{self, oneshot}, }; - fn set_origin(base: Uri, req: Request) -> Result, Error> { - let (mut parts, body) = req.into_parts(); - let (scheme, authority) = { - let scheme = base.scheme().unwrap_or(&Scheme::HTTP); - let authority = base.authority().expect("Authority not found"); - (scheme, authority) - }; - let path = parts.uri.path_and_query().expect("PathAndQuery not found"); - - let uri = Uri::builder() - .scheme(scheme.clone()) - .authority(authority.clone()) - .path_and_query(path.clone()) - .build() - .expect("Unable to build URI"); - - parts.uri = uri; - Ok(Request::from_parts(parts, body)) - } - #[cfg(test)] async fn next_event(req: &Request) -> Result, Error> { let path = "/2018-06-01/runtime/invocation/next"; @@ -103,7 +84,7 @@ mod endpoint_tests { trace_id: "Root=1-5bef4de7-ad49b0e87f6ef6c87fc2e700;Parent=9a9197af755a6419", body: serde_json::to_vec(&body)?, }; - rsp.into_rsp().map_err(|e| e.into()) + rsp.into_rsp() } #[cfg(test)] @@ -141,9 +122,9 @@ mod endpoint_tests { .path_and_query() .expect("PathAndQuery not found") .as_str() - .split("/") + .split('/') .collect::>(); - match &path[1..] { + match path[1..] { ["2018-06-01", "runtime", "invocation", "next"] => next_event(&req).await, ["2018-06-01", "runtime", "invocation", id, "response"] => complete_event(&req, id).await, ["2018-06-01", "runtime", "invocation", id, "error"] => event_err(&req, id).await, @@ -160,13 +141,13 @@ mod endpoint_tests { let conn = Http::new().serve_connection(io, service_fn(handle_incoming)); select! { _ = rx => { - return Ok(()) + Ok(()) } res = conn => { match res { - Ok(()) => return Ok(()), + Ok(()) => Ok(()), Err(e) => { - return Err(e); + Err(e) } } } @@ -175,20 +156,19 @@ mod endpoint_tests { #[tokio::test] async fn test_next_event() -> Result<(), Error> { - let (client, server) = crate::simulated::chan(); let base = Uri::from_static("http://localhost:9001"); + let (client, server) = crate::simulated::chan(); let (tx, rx) = sync::oneshot::channel(); let server = tokio::spawn(async { handle(server, rx).await.expect("Unable to handle request"); }); - let conn = SimulatedConnector { inner: client }; - let client = hyper::Client::builder().build(conn); + let conn = simulated::Connector { inner: client }; + let client = Client::with(base, conn); let req = NextEventRequest.into_req()?; - let req = set_origin(base, req)?; - let rsp = client.request(req).await.expect("Unable to send request"); + let rsp = client.call(req).await.expect("Unable to send request"); assert_eq!(rsp.status(), StatusCode::OK); let header = "lambda-runtime-deadline-ms"; @@ -213,17 +193,16 @@ mod endpoint_tests { handle(server, rx).await.expect("Unable to handle request"); }); - let conn = SimulatedConnector { inner: client }; - let client = hyper::Client::builder().build(conn); + let conn = simulated::Connector { inner: client }; + let client = Client::with(base, conn); let req = EventCompletionRequest { request_id: "156cb537-e2d4-11e8-9b34-d36013741fb9", body: "done", }; let req = req.into_req()?; - let req = set_origin(base, req)?; - let rsp = client.request(req).await?; + let rsp = client.call(req).await?; assert_eq!(rsp.status(), StatusCode::ACCEPTED); // shutdown server @@ -245,8 +224,8 @@ mod endpoint_tests { handle(server, rx).await.expect("Unable to handle request"); }); - let conn = SimulatedConnector { inner: client }; - let client = hyper::Client::builder().build(conn); + let conn = simulated::Connector { inner: client }; + let client = Client::with(base, conn); let req = EventErrorRequest { request_id: "156cb537-e2d4-11e8-9b34-d36013741fb9", @@ -256,8 +235,7 @@ mod endpoint_tests { }, }; let req = req.into_req()?; - let req = set_origin(base, req)?; - let rsp = client.request(req).await?; + let rsp = client.call(req).await?; assert_eq!(rsp.status(), StatusCode::ACCEPTED); // shutdown server @@ -268,4 +246,39 @@ mod endpoint_tests { Err(_) => unreachable!("This branch shouldn't be reachable"), } } + + #[tokio::test] + async fn successful_end_to_end_run() -> Result<(), Error> { + let (client, server) = crate::simulated::chan(); + let (tx, rx) = sync::oneshot::channel(); + let base = Uri::from_static("http://localhost:9001"); + + let server = tokio::spawn(async { + handle(server, rx).await.expect("Unable to handle request"); + }); + let conn = simulated::Connector { inner: client }; + + let runtime = Runtime::builder() + .with_endpoint(base) + .with_connector(conn) + .build() + .expect("Unable to build runtime"); + + async fn func(event: serde_json::Value, _: crate::Context) -> Result { + Ok(event) + } + let f = crate::handler_fn(func); + + let client = &runtime.client; + let incoming = incoming(client).take(1); + runtime.run(incoming, f).await?; + + // shutdown server + tx.send(()).expect("Receiver has been dropped"); + match server.await { + Ok(_) => Ok(()), + Err(e) if e.is_panic() => return Err::<(), Error>(e.into()), + Err(_) => unreachable!("This branch shouldn't be reachable"), + } + } } diff --git a/lambda/src/lib.rs b/lambda/src/lib.rs index 721755c9..cff12c30 100644 --- a/lambda/src/lib.rs +++ b/lambda/src/lib.rs @@ -1,4 +1,4 @@ -#![deny(clippy::all, clippy::pedantic, clippy::nursery, clippy::cargo)] +#![deny(clippy::all, clippy::cargo)] #![warn(missing_docs, nonstandard_style, rust_2018_idioms)] //! The official Rust runtime for AWS Lambda. @@ -41,6 +41,7 @@ //! [Tokio]: https://docs.rs/tokio/ pub use crate::types::Context; use client::Client; +use hyper::client::{connect::Connection, HttpConnector}; pub use lambda_attributes::lambda; use serde::{Deserialize, Serialize}; use std::{ @@ -49,7 +50,11 @@ use std::{ future::Future, sync::Arc, }; -use tokio::stream::{Stream, StreamExt}; +use tokio::{ + io::{AsyncRead, AsyncWrite}, + stream::{Stream, StreamExt}, +}; +use tower_service::Service; mod client; mod requests; @@ -134,6 +139,158 @@ where } } +#[non_exhaustive] +#[derive(Debug, PartialEq)] +enum BuilderError { + UnsetUri, +} + +struct Runtime = HttpConnector> { + client: Client, +} + +impl Runtime { + pub fn builder() -> RuntimeBuilder { + RuntimeBuilder { + connector: HttpConnector::new(), + uri: None, + } + } +} + +impl Runtime +where + C: Service + Clone + Send + Sync + Unpin + 'static, + >::Future: Unpin + Send, + >::Error: Into>, + >::Response: AsyncRead + AsyncWrite + Connection + Unpin + Send + 'static, +{ + pub async fn run( + &self, + incoming: impl Stream, Error>> + Send, + handler: F, + ) -> Result<(), Error> + where + F: Handler + Send + Sync + 'static, + >::Fut: Future>::Error>> + Send + Sync + 'static, + >::Error: fmt::Debug + Send + Sync + 'static, + A: for<'de> Deserialize<'de> + Send + Sync + 'static, + B: Serialize + Send + Sync + 'static, + { + let client = &self.client; + let handler = Arc::new(handler); + tokio::pin!(incoming); + while let Some(event) = incoming.next().await { + let event = event?; + let (parts, body) = event.into_parts(); + + let ctx: Context = Context::try_from(parts.headers)?; + let body = hyper::body::to_bytes(body).await?; + let body = serde_json::from_slice(&body)?; + + let handler = Arc::clone(&handler); + let request_id = &ctx.request_id.clone(); + let task = tokio::spawn(async move { handler.call(body, ctx) }); + + let req = match task.await { + Ok(response) => match response.await { + Ok(response) => EventCompletionRequest { + request_id, + body: response, + } + .into_req(), + Err(err) => EventErrorRequest { + request_id, + diagnostic: Diagnostic { + error_type: type_name_of_val(&err).to_owned(), + error_message: format!("{:?}", err), + }, + } + .into_req(), + }, + Err(err) if err.is_panic() => EventErrorRequest { + request_id, + diagnostic: Diagnostic { + error_type: type_name_of_val(&err).to_owned(), + error_message: "Lambda panicked!".to_owned(), + }, + } + .into_req(), + Err(_) => unreachable!("tokio::task should not be canceled"), + }; + let req = req?; + client.call(req).await.expect("Unable to send response to Runtime APIs"); + } + Ok(()) + } +} + +struct RuntimeBuilder = hyper::client::HttpConnector> { + connector: C, + uri: Option, +} + +impl RuntimeBuilder +where + C: Service + Clone + Send + Sync + Unpin + 'static, + >::Future: Unpin + Send, + >::Error: Into>, + >::Response: AsyncRead + AsyncWrite + Connection + Unpin + Send + 'static, +{ + pub fn with_connector(self, connector: C2) -> RuntimeBuilder + where + C2: Service + Clone + Send + Sync + Unpin + 'static, + >::Future: Unpin + Send, + >::Error: Into>, + >::Response: AsyncRead + AsyncWrite + Connection + Unpin + Send + 'static, + { + RuntimeBuilder { + connector, + uri: self.uri, + } + } + + pub fn with_endpoint(self, uri: http::Uri) -> Self { + Self { uri: Some(uri), ..self } + } + + pub fn build(self) -> Result, BuilderError> { + let uri = match self.uri { + Some(uri) => uri, + None => return Err(BuilderError::UnsetUri), + }; + let client = Client::with(uri, self.connector); + + Ok(Runtime { client }) + } +} + +#[test] +fn test_builder() { + let runtime = Runtime::builder() + .with_connector(HttpConnector::new()) + .with_endpoint(http::Uri::from_static("http://nomatter.com")) + .build(); + + runtime.unwrap(); +} + +fn incoming(client: &Client) -> impl Stream, Error>> + Send + '_ +where + C: Service + Clone + Send + Sync + Unpin + 'static, + >::Future: Unpin + Send, + >::Error: Into>, + >::Response: AsyncRead + AsyncWrite + Connection + Unpin + Send + 'static, +{ + async_stream::stream! { + loop { + let req = NextEventRequest.into_req().expect("Unable to construct request"); + let res = client.call(req).await; + yield res; + } + } +} + /// Starts the Lambda Rust runtime and begins polling for events on the [Lambda /// Runtime APIs](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html). /// @@ -165,80 +322,15 @@ where { let config = Config::from_env()?; let uri = config.endpoint.try_into().expect("Unable to convert to URL"); - let client = Client::with(uri, hyper::Client::new()); - let incoming = incoming(&client); - run_inner(&client, incoming, handler).await?; - - Ok(()) -} - -fn incoming(client: &Client) -> impl Stream, Error>> + '_ { - async_stream::stream! { - loop { - let req = NextEventRequest.into_req().expect("Unable to construct request"); - let res = client.call(req).await; - yield res; - } - } -} - -async fn run_inner( - client: &Client, - incoming: impl Stream, Error>>, - handler: F, -) -> Result<(), Error> -where - F: Handler + Send + Sync + 'static, - >::Fut: Future>::Error>> + Send + Sync + 'static, - >::Error: fmt::Debug + Send + Sync + 'static, - A: for<'de> Deserialize<'de> + Send + Sync + 'static, - B: Serialize + Send + Sync + 'static, -{ - let handler = Arc::new(handler); - tokio::pin!(incoming); - while let Some(event) = incoming.next().await { - let event = event?; - let (parts, body) = event.into_parts(); - - let ctx: Context = Context::try_from(parts.headers)?; - let body = hyper::body::to_bytes(body).await?; - let body = serde_json::from_slice(&body)?; - - let handler = Arc::clone(&handler); - let request_id = &ctx.request_id.clone(); - let task = tokio::spawn(async move { handler.call(body, ctx) }); - - let req = match task.await { - Ok(response) => match response.await { - Ok(response) => EventCompletionRequest { - request_id, - body: response, - } - .into_req(), - Err(err) => EventErrorRequest { - request_id, - diagnostic: Diagnostic { - error_type: type_name_of_val(&err).to_owned(), - error_message: format!("{:?}", err), - }, - } - .into_req(), - }, - Err(err) if err.is_panic() => EventErrorRequest { - request_id, - diagnostic: Diagnostic { - error_type: type_name_of_val(&err).to_owned(), - error_message: "Lambda panicked!".to_owned(), - }, - } - .into_req(), - Err(_) => unreachable!("tokio::task should not be canceled"), - }; - let req = req?; - client.call(req).await.expect("Unable to send response to Runtime APIs"); - } + let runtime = Runtime::builder() + .with_connector(HttpConnector::new()) + .with_endpoint(uri) + .build() + .expect("Unable create runtime"); - Ok(()) + let client = &runtime.client; + let incoming = incoming(client).take(1); + runtime.run(incoming, handler).await } fn type_name_of_val(_: T) -> &'static str { diff --git a/lambda/src/requests.rs b/lambda/src/requests.rs index 2d691b94..a89f1689 100644 --- a/lambda/src/requests.rs +++ b/lambda/src/requests.rs @@ -134,7 +134,7 @@ struct InitErrorRequest; impl IntoRequest for InitErrorRequest { fn into_req(self) -> Result, Error> { - let uri = format!("/2018-06-01/runtime/init/error"); + let uri = "/2018-06-01/runtime/init/error".to_string(); let uri = Uri::from_str(&uri)?; let req = Request::builder() diff --git a/lambda/src/simulated.rs b/lambda/src/simulated.rs index ea41e2d5..a37c63a8 100644 --- a/lambda/src/simulated.rs +++ b/lambda/src/simulated.rs @@ -37,11 +37,11 @@ pub(crate) fn chan() -> (SimStream, SimStream) { } #[derive(Clone)] -pub struct SimulatedConnector { +pub struct Connector { pub inner: SimStream, } -impl Service for SimulatedConnector { +impl Service for Connector { type Response = SimStream; type Error = std::io::Error; type Future = Pin> + Send>>; @@ -209,7 +209,7 @@ mod tests { client.write_all(b"Ping").await.expect("Write should succeed"); // Verify we can read it from side 2 - let mut read_on_server = [0u8; 4]; + let mut read_on_server = [0_u8; 4]; server .read_exact(&mut read_on_server) .await @@ -220,7 +220,7 @@ mod tests { server.write_all(b"Pong").await.expect("Write should succeed"); // Verify we can read it from side 1 - let mut read_on_client = [0u8; 4]; + let mut read_on_client = [0_u8; 4]; client .read_exact(&mut read_on_client) .await From a8ef3c3aa2f401e0054b2069e0fcfcf59c61fecd Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 22 Jul 2020 05:08:55 +0000 Subject: [PATCH 07/30] Log handler errors in runtime. Issue #241 --- Cargo.lock | 666 ++++++++++++++++-------------- lambda/Cargo.toml | 14 +- lambda/examples/error-handling.rs | 110 +++++ lambda/examples/readme.md | 156 +++++++ lambda/src/client.rs | 57 +-- lambda/src/lib.rs | 29 +- 6 files changed, 646 insertions(+), 386 deletions(-) create mode 100644 lambda/examples/error-handling.rs create mode 100644 lambda/examples/readme.md diff --git a/Cargo.lock b/Cargo.lock index 5cd113cd..329fd8fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,7 +2,7 @@ # It is not intended for manual editing. [[package]] name = "arc-swap" -version = "0.4.4" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -11,7 +11,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "async-stream-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -19,9 +19,19 @@ name = "async-stream-impl" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "hermit-abi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -31,7 +41,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "base64" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -41,7 +51,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bytes" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -49,14 +59,34 @@ name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "chrono" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-integer 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "colored" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "dtoa" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "fnv" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -75,120 +105,132 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures" -version = "0.3.1" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-channel 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-executor 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "futures-channel" -version = "0.3.1" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "futures-core" -version = "0.3.1" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures-executor" -version = "0.3.1" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "futures-io" -version = "0.3.1" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures-macro" -version = "0.3.1" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.16 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "futures-sink" -version = "0.3.1" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures-task" -version = "0.3.1" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "once_cell 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "futures-util" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-macro 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.16 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-nested 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "h2" -version = "0.2.1" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hashbrown" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "hermit-abi" -version = "0.1.6" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "http" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -196,8 +238,8 @@ name = "http-body" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -207,24 +249,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hyper" -version = "0.13.1" +version = "0.13.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "h2 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-channel 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "h2 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "http-body 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)", + "socket2 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", "tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -235,15 +277,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "indexmap" -version = "1.3.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -251,12 +294,12 @@ name = "iovec" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "itoa" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -273,18 +316,18 @@ name = "lambda" version = "0.1.0" dependencies = [ "async-stream 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)", "lambda-attributes 0.1.0", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.56 (registry+https://github.com/rust-lang/crates.io-index)", + "simple-error 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "simple_logger 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", "tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing-error 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing-futures 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -292,25 +335,25 @@ name = "lambda-attributes" version = "0.1.0" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "lambda_http" version = "0.2.0-beta.1" dependencies = [ - "base64 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "lambda 0.1.0", "lambda-attributes 0.1.0", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.56 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -320,12 +363,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.66" +version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" -version = "0.4.8" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -343,12 +386,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memchr" -version = "2.3.0" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "mio" -version = "0.6.21" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -356,33 +399,33 @@ dependencies = [ "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "mio-named-pipes" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", - "miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)", + "miow 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "mio-uds" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -391,39 +434,61 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "miow" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "socket2 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "net2" -version = "0.2.33" +version = "0.2.34" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-integer" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-traits" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num_cpus" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "hermit-abi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "once_cell" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "percent-encoding" version = "2.1.0" @@ -431,45 +496,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "pin-project" -version = "0.4.8" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "pin-project-internal 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-internal 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "pin-project-internal" -version = "0.4.8" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "pin-project-lite" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "pin-utils" -version = "0.1.0-alpha.4" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro-hack" -version = "0.5.11" +version = "0.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "proc-macro-nested" -version = "0.1.3" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -482,56 +542,56 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.8" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "quote" -version = "1.0.2" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "redox_syscall" -version = "0.1.56" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ryu" -version = "1.0.2" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.104" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.104" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" -version = "1.0.45" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -539,27 +599,36 @@ name = "serde_urlencoded" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "dtoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "dtoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "sharded-slab" -version = "0.0.9" +name = "signal-hook-registry" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "arc-swap 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "signal-hook-registry" -version = "1.2.0" +name = "simple-error" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "simple_logger" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", + "colored 1.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -567,86 +636,85 @@ name = "slab" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "smallvec" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "socket2" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "1.0.14" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "time" -version = "0.1.42" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tinyvec" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "tokio" -version = "0.2.11" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-named-pipes 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)", + "mio-named-pipes 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "mio-uds 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-lite 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-macros 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-macros 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-macros" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-util" -version = "0.2.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-lite 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -656,61 +724,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "tracing" -version = "0.1.13" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing-attributes 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing-core 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tracing-core" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "tracing-error" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "tracing 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing-subscriber 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tracing-futures" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "pin-project 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tracing-subscriber" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "sharded-slab 0.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "try-lock" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -723,10 +755,10 @@ dependencies = [ [[package]] name = "unicode-normalization" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "smallvec 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tinyvec 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -736,7 +768,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicode-xid" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -754,8 +786,8 @@ name = "want" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "try-lock 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -765,7 +797,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -797,93 +829,97 @@ dependencies = [ ] [metadata] -"checksum arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d7b8a9123b8027467bce0099fe556c628a53c8d83df0507084c31e9ba2e39aff" +"checksum arc-swap 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034" "checksum async-stream 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "22068c0c19514942eefcfd4daf8976ef1aad84e61539f95cd200c35202f80af5" "checksum async-stream-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "25f9db3b38af870bf7e5cc649167533b493928e50744e2c30ae350230b414670" +"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" -"checksum base64 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "53d1ccbaf7d9ec9537465a97bf19edc1a4e158ecb49fc16178202238c569cc42" +"checksum base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -"checksum bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" +"checksum bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum dtoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4358a9e11b9a09cf52383b451b49a169e8d797b68aa02301ff586d70d9661ea3" -"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" +"checksum chrono 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "c74d84029116787153e02106bf53e66828452a4b325cc8652b788b5967c0a0b6" +"checksum colored 1.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59" +"checksum dtoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b" +"checksum fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6f16056ecbb57525ff698bb955162d0cd03bee84e6241c27ff75c08d8ca5987" -"checksum futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fcae98ca17d102fd8a3603727b9259fcf7fa4239b603d2142926189bc8999b86" -"checksum futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866" -"checksum futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e274736563f686a837a0568b478bdabfeaec2dca794b5649b04e2fe1627c231" -"checksum futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e676577d229e70952ab25f3945795ba5b16d63ca794ca9d2c860e5595d20b5ff" -"checksum futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "52e7c56c15537adb4f76d0b7a76ad131cb4d2f4f32d3b0bcabcbe1c7c5e87764" -"checksum futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "171be33efae63c2d59e6dbba34186fe0d6394fb378069a76dfd80fdcffd43c16" -"checksum futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9" -"checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" -"checksum h2 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9433d71e471c1736fd5a61b671fc0b148d7a2992f666c958d03cd8feb3b88d1" -"checksum hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772" -"checksum http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b708cc7f06493459026f53b9a61a7a121a5d1ec6238dee58ea4941132b30156b" +"checksum futures 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1e05b85ec287aac0dc34db7d4a569323df697f9c55b99b15d6b4ef8cde49f613" +"checksum futures-channel 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5" +"checksum futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" +"checksum futures-executor 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "10d6bb888be1153d3abeb9006b11b02cf5e9b209fda28693c31ae1e4e012e314" +"checksum futures-io 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" +"checksum futures-macro 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39" +"checksum futures-sink 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc" +"checksum futures-task 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" +"checksum futures-util 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" +"checksum h2 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "993f9e0baeed60001cf565546b0d3dbe6a6ad23f2bd31644a133c641eccf6d53" +"checksum hashbrown 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34f595585f103464d8d2f6e9864682d74c1601fed5e07d62b1c9058dba8246fb" +"checksum hermit-abi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9" +"checksum http 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" "checksum http-body 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" "checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" -"checksum hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8bf49cfb32edee45d890537d9057d1b02ed55f53b7b6a30bae83a38c9231749e" +"checksum hyper 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3e68a8dd9716185d9e64ea473ea6ef63529252e3e27623295a0378a19665d5eb" "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" -"checksum indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b54058f0a6ff80b6803da8faf8997cde53872b38f4023728f6830b06cd3c0dc" +"checksum indexmap 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b88cd59ee5f71fea89a62248fc8f387d44400cefe05ef548466d61ced9029a7" "checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -"checksum itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" +"checksum itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +"checksum libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)" = "bd7d4bd64732af4bf3a67f367c27df8520ad7e230c5817b8ff485864d80242b9" +"checksum log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" "checksum maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" -"checksum memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" -"checksum mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" -"checksum mio-named-pipes 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f5e374eff525ce1c5b7687c4cef63943e7686524a387933ad27ca7ec43779cb3" -"checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" +"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +"checksum mio 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)" = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +"checksum mio-named-pipes 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" +"checksum mio-uds 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -"checksum miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "396aa0f2003d7df8395cb93e09871561ccc3e785f0acb369170e8cc74ddf9226" -"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" -"checksum num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" +"checksum miow 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e" +"checksum net2 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)" = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" +"checksum num-integer 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" +"checksum num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" +"checksum num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +"checksum once_cell 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" "checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" -"checksum pin-project 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7804a463a8d9572f13453c516a5faea534a2403d7ced2f0c7e100eeff072772c" -"checksum pin-project-internal 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "385322a45f2ecf3410c68d2a549a4a2685e8051d0f278e39743ff4e451cb9b3f" -"checksum pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae" -"checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" -"checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" -"checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" +"checksum pin-project 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)" = "12e3a6cdbfe94a5e4572812a0201f8c0ed98c1c452c7b8563ce2276988ef9c17" +"checksum pin-project-internal 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)" = "6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7" +"checksum pin-project-lite 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "282adbf10f2698a7a77f8e983a74b2d18176c19a7fd32a45446139ae7b02b715" +"checksum pin-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +"checksum proc-macro-hack 0.5.16 (registry+https://github.com/rust-lang/crates.io-index)" = "7e0456befd48169b9f13ef0f0ad46d492cf9d2dbb918bcf38e01eed4ce3ec5e4" +"checksum proc-macro-nested 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" -"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" -"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" -"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" -"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" -"checksum serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "eab8f15f15d6c41a154c1b128a22f2dfabe350ef53c40953d84e36155c91192b" +"checksum proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12" +"checksum quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +"checksum redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)" = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +"checksum ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +"checksum serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)" = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3" +"checksum serde_derive 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)" = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e" +"checksum serde_json 1.0.56 (registry+https://github.com/rust-lang/crates.io-index)" = "3433e879a558dde8b5e8feb2a04899cf34fdde1fafb894687e52105fc1162ac3" "checksum serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" -"checksum sharded-slab 0.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "06d5a3f5166fb5b42a5439f2eee8b9de149e235961e3eb21c5808fc3ea17ff3e" "checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" +"checksum simple-error 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "339844c9af2d844b9230bb28e8f819a7790cbf20a29b5cbd2b59916a03a1ef51" +"checksum simple_logger 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fea0c4611f32f4c2bac73754f22dca1f57e6c1945e0590dae4e5f2a077b92367" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -"checksum smallvec 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" -"checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" -"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" -"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -"checksum tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8fdd17989496f49cdc57978c96f0c9fe5e4a58a8bddc6813c449a4624f6a030b" -"checksum tokio-macros 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f4b1e7ed7d5d4c2af3d999904b0eebe76544897cdbfb2b9684bed2174ab20f7c" -"checksum tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" +"checksum socket2 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" +"checksum syn 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)" = "fb7f4c519df8c117855e19dd8cc851e89eb746fe7a73f0157e0d95fdec5369b0" +"checksum time 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +"checksum tinyvec 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed" +"checksum tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" +"checksum tokio-macros 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" +"checksum tokio-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" "checksum tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" -"checksum tracing 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1721cc8cf7d770cc4257872507180f35a4797272f5962f24c806af9e7faf52ab" -"checksum tracing-attributes 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "7fbad39da2f9af1cae3016339ad7f2c7a9e870f12e8fd04c4fd7ef35b30c0d2b" -"checksum tracing-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0aa83a9a47081cd522c09c81b31aec2c9273424976f922ad61c053b58350b715" -"checksum tracing-error 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d7c0b83d4a500748fa5879461652b361edf5c9d51ede2a2ac03875ca185e24" -"checksum tracing-futures 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" -"checksum tracing-subscriber 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1d53c40489aa69c9aed21ff483f26886ca8403df33bdc2d2f87c60c1617826d2" -"checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" +"checksum tracing 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "c2e2a2de6b0d5cbb13fc21193a2296888eaab62b6044479aafb3c54c01c29fcd" +"checksum tracing-core 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "94ae75f0d28ae10786f3b1895c55fe72e79928fd5ccdebb5438c75e93fec178f" +"checksum try-lock 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -"checksum unicode-normalization 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" +"checksum unicode-normalization 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +"checksum unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" "checksum url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" "checksum want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +"checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/lambda/Cargo.toml b/lambda/Cargo.toml index eb718e80..5e504c85 100644 --- a/lambda/Cargo.toml +++ b/lambda/Cargo.toml @@ -6,9 +6,7 @@ description = "AWS Lambda Runtime." edition = "2018" [features] -# no features by default -default = ["simulated", "derive"] -simulated = [] +default = ["derive"] # `derive` is commonly used, so is enabled by default derive = ["lambda-attributes"] [dependencies] @@ -22,6 +20,10 @@ http = "0.2" lambda-attributes = { path = "../lambda-attributes", version = "0.1.0", optional = true} async-stream = "0.2" futures = "0.3" -tracing = "0.1.13" -tracing-futures = "0.2.3" -tracing-error = "0.1.2" +log = "0.4" + + +[dev-dependencies] +# used in some of the examples +simple-error = "0.2" +simple_logger = "1.6" diff --git a/lambda/examples/error-handling.rs b/lambda/examples/error-handling.rs new file mode 100644 index 00000000..2e2799ea --- /dev/null +++ b/lambda/examples/error-handling.rs @@ -0,0 +1,110 @@ +/// See https://github.com/awslabs/aws-lambda-rust-runtime for more info on Rust runtime for AWS Lambda +use lambda::handler_fn; +use serde::{Deserialize, Serialize}; +use serde_json::{json, Value}; +use simple_logger; +use simple_error; +use std::fs::File; + + +/// A shorthand for `Box` type required by aws-lambda-rust-runtime. +pub type Error = Box; + +#[derive(Debug, Serialize)] +struct CustomError { + is_authenticated: bool, + req_id: String, + msg: String, +} + +impl std::error::Error for CustomError { + // this implementation required `Debug` and `Display` traits +} + +impl std::fmt::Display for CustomError { + /// Display the error struct as a JSON string + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let err_as_json = json!(self).to_string(); + write!(f, "{}", err_as_json) + } +} + +/// The entry point called by aws-lambda-rust-runtime client for every new Lambda request. +#[tokio::main] +async fn main() -> Result<(), Error> { + simple_logger::init_with_level(log::Level::Debug)?; // Note, this can only be called once! + + // call the actual handler of the request + let func = handler_fn(func); + lambda::run(func).await?; + Ok(()) +} + +/// The actual handler of the Lambda request. +pub(crate) async fn func(event: Value, ctx: lambda::Context) -> Result { + // convert the JSON request to a struct + let req = serde_json::from_value::(event); + + // check if the conversion succeeded and what action was requested + match req { + Err(e) => { + // conversion from JSON to `Request` struct failed + // return serde_json error + return Err(Box::new(e)); + } + Ok(v) if v.event_type == EventType::SimpleError => { + // generate a simple text message error using `simple_error` crate + return Err(Box::new(simple_error::SimpleError::new( + "A simple error as requested!", + ))); + } + Ok(v) if v.event_type == EventType::CustomError => { + // generate a custom error using our own structure + let cust_err = CustomError { + is_authenticated: ctx.identity.is_some(), + req_id: ctx.request_id, + msg: "A custom error as requested!".into(), + }; + return Err(Box::new(cust_err)); + } + Ok(v) if v.event_type == EventType::ExternalError => { + // try to open a non-existent file to get an error and propagate it with `?` + let _file = File::open("non-existent-file.txt")?; + + // it should never execute past the above line + panic!(); + } + Ok(_) => { + // generate and return an OK response in JSON format + let resp = Response { + req_id: ctx.request_id, + msg: "OK".into(), + }; + + return Ok(json!(resp)); + } + } +} + +/// A simple Lambda response structure. +#[derive(Serialize)] +struct Response { + req_id: String, + msg: String, +} + +/// A simple Lambda request structure with just one field +/// that tells the Lambda what is expected of it. +#[derive(Deserialize)] +struct Request { + event_type: EventType, +} + +/// Event types that tell our Lambda what to do do. +#[derive(Deserialize, PartialEq)] +enum EventType { + Response, + ExternalError, + SimpleError, + CustomError, +} diff --git a/lambda/examples/readme.md b/lambda/examples/readme.md new file mode 100644 index 00000000..43094e22 --- /dev/null +++ b/lambda/examples/readme.md @@ -0,0 +1,156 @@ + +## How to compile and run the examples + +1. Compile the example you want to run + +``` +cargo build --release --target x86_64-unknown-linux-musl --example error-handling +``` +2. Prepare the package +``` +cp ./target/x86_64-unknown-linux-musl/release/examples/error-handling ./bootstrap && zip lambda.zip bootstrap && rm bootstrap +``` +3. Upload to AWS Lambda +``` +aws lambda update-function-code --region us-east-1 --function-name ReturnValue --zip-file fileb://lambda.zip +``` +_Remember to replace the names and IDs with your own values._ + + +## Error handling examples for aws-lambda-rust-runtime + +#### Error logging by the runtime + +Errors are logged by the runtime only if `log` is initialised by the handler. +These examples use `simple_logger`, but you can use any other provider that works with `log`. +``` +simple_logger::init_with_level(log::Level::Debug)?; +``` + +#### Sample log output + +The following input/output examples correspond to different `match` arms in the handler of `error-handling.rs`. + +### Invalid JSON input + +Test input: +```json +{ + "event_type": "WrongType" +} +``` + +Lambda output: +``` +{ + "errorType": "alloc::boxed::Box", + "errorMessage": "unknown variant `WrongType`, expected one of `Response`, `ExternalError`, `SimpleError`, `CustomError`" +} +``` + +CloudWatch records: +``` +START RequestId: b98e07c6-e2ba-4ca6-9968-d0b94729ddba Version: $LATEST +2020-07-21 04:28:52,630 ERROR [lambda] unknown variant `WrongType`, expected one of `Response`, `ExternalError`, `SimpleError`, `CustomError` +END RequestId: b98e07c6-e2ba-4ca6-9968-d0b94729ddba +REPORT RequestId: b98e07c6-e2ba-4ca6-9968-d0b94729ddba Duration: 2.06 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 28 MB Init Duration: 33.67 ms +``` + +### A simple text-only error + +Test input: +```json +{ + "event_type": "SimpleError" +} +``` + +Lambda output: +``` +{ + "errorType": "alloc::boxed::Box", + "errorMessage": "A simple error as requested!" +} +``` + +CloudWatch records: +``` +START RequestId: 77c66dbf-bd60-4f77-8453-682d0bceba91 Version: $LATEST +2020-07-21 04:35:28,044 ERROR [lambda] A simple error as requested! +END RequestId: 77c66dbf-bd60-4f77-8453-682d0bceba91 +REPORT RequestId: 77c66dbf-bd60-4f77-8453-682d0bceba91 Duration: 0.98 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 28 MB +``` + +### A custom error with JSON output for Display trait + +Test input: +```json +{ + "event_type": "CustomError" +} +``` + +Lambda output: +``` +{ + "errorType": "alloc::boxed::Box", + "errorMessage": "{\"is_authenticated\":false,\"msg\":\"A custom error as requested!\",\"req_id\":\"b46b0588-1383-4224-bc7a-42b0d61930c1\"}" +} +``` + +CloudWatch records: +``` +START RequestId: b46b0588-1383-4224-bc7a-42b0d61930c1 Version: $LATEST +2020-07-21 04:39:00,133 ERROR [lambda] {"is_authenticated":false,"msg":"A custom error as requested!","req_id":"b46b0588-1383-4224-bc7a-42b0d61930c1"} +END RequestId: b46b0588-1383-4224-bc7a-42b0d61930c1 +REPORT RequestId: b46b0588-1383-4224-bc7a-42b0d61930c1 Duration: 0.91 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 29 MB +``` + +### A 3rd party error from _std::fs::File::open_ + +Test input: +```json +{ + "event_type": "ExternalError" +} +``` + +Lambda output: +``` +{ + "errorType": "alloc::boxed::Box", + "errorMessage": "No such file or directory (os error 2)" +} +``` + +CloudWatch records: +``` +START RequestId: 893d24e5-cb79-4f6f-bae0-36304c62e9da Version: $LATEST +2020-07-21 04:43:56,254 ERROR [lambda] No such file or directory (os error 2) +END RequestId: 893d24e5-cb79-4f6f-bae0-36304c62e9da +REPORT RequestId: 893d24e5-cb79-4f6f-bae0-36304c62e9da Duration: 1.15 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 29 MB +``` + +### A response to a successful Lambda execution + +Test input: +```json +{ + "event_type": "Response" +} +``` + +Lambda output: +``` +{ + "msg": "OK", + "req_id": "9752a3ad-6566-44e4-aafd-74db1fd4f361" +} +``` + +CloudWatch records: +``` +START RequestId: 9752a3ad-6566-44e4-aafd-74db1fd4f361 Version: $LATEST +END RequestId: 9752a3ad-6566-44e4-aafd-74db1fd4f361 +REPORT RequestId: 9752a3ad-6566-44e4-aafd-74db1fd4f361 Duration: 0.89 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 29 MB +``` \ No newline at end of file diff --git a/lambda/src/client.rs b/lambda/src/client.rs index 64313ebf..5a020d73 100644 --- a/lambda/src/client.rs +++ b/lambda/src/client.rs @@ -7,6 +7,7 @@ use http::{ HeaderValue, Method, Request, Response, StatusCode, Uri, }; use hyper::{client::HttpConnector, server::conn::Http, service::service_fn, Body}; +use log::{error, info}; use serde_json::json; use std::convert::TryFrom; use tokio::{ @@ -14,9 +15,7 @@ use tokio::{ select, sync::oneshot, }; -use tracing::{error, info, instrument}; -#[instrument] async fn hello(req: Request) -> Result, Error> { Ok(Response::new(Body::from("hello"))) } @@ -38,7 +37,6 @@ async fn handle_incoming(req: Request) -> Result, Error> { } } -#[instrument(skip(io, rx))] async fn handle(io: I, rx: oneshot::Receiver<()>) -> Result<(), hyper::error::Error> where I: AsyncRead + AsyncWrite + Unpin + 'static, @@ -53,7 +51,7 @@ where match res { Ok(()) => return Ok(()), Err(e) => { - error!(message = "Got error serving connection", e = %e); + error!("Got error serving connection {}", e); return Err(e); } } @@ -275,55 +273,4 @@ mod endpoint_tests { Err(_) => unreachable!("This branch shouldn't be reachable"), } } - - // #[tokio::test] - // async fn run_end_to_end() -> Result<(), Error> { - // use serde_json::Value; - - // let (client, server) = crate::simulated::chan(); - - // let (tx, rx) = sync::oneshot::channel(); - // let server = tokio::spawn(async move { handle(server, rx) }); - - // async fn handler(s: Value) -> Result { - // INVOCATION_CTX.with(|_ctx| {}); - // Ok(s) - // } - // let handler = handler_fn(handler); - // let client = tokio::spawn(async move { - // run_simulated(handler, &url).await?; - // Ok::<(), Error>(()) - // }); - // race!(client, server); - // Ok(()) - // } - - // #[tokio::test] - // async fn test_stream_handler() -> Result<(), Error> { - // let (client, server) = crate::simulated::chan(); - // let req = Request::builder() - // .method(Method::GET) - // .uri("http://httpbin.org") - // .body(Body::empty()) - // .expect("Can't build request"); - - // let conn = SimulatedConnector { inner: client }; - // let client = hyper::Client::builder().build(conn); - - // let (tx, rx) = sync::oneshot::channel(); - // let server = tokio::spawn(async { - // handle(server, rx).await.expect("Unable to handle request"); - // }); - - // let rsp = client.request(req).await.expect("Unable to send request"); - // assert_eq!(rsp.status(), http::StatusCode::OK); - - // // shutdown server - // tx.send(()).expect("Receiver has been dropped"); - // match server.await { - // Ok(_) => Ok(()), - // Err(e) if e.is_panic() => return Err::<(), anyhow::Error>(e.into()), - // Err(_) => unreachable!("This branch shouldn't be reachable"), - // } - // } } diff --git a/lambda/src/lib.rs b/lambda/src/lib.rs index 24ef4929..e3e8d102 100644 --- a/lambda/src/lib.rs +++ b/lambda/src/lib.rs @@ -37,6 +37,7 @@ pub use crate::types::Context; use client::Client; use futures::stream::{Stream, StreamExt}; pub use lambda_attributes::lambda; +use log::error; use serde::{Deserialize, Serialize}; use std::{ convert::{TryFrom, TryInto}, @@ -146,7 +147,7 @@ where pub async fn run(handler: F) -> Result<(), Error> where F: Handler, - >::Error: fmt::Debug, + >::Error: fmt::Display, A: for<'de> Deserialize<'de>, B: Serialize, { @@ -164,7 +165,7 @@ where pub async fn run_simulated(handler: F, url: &str) -> Result<(), Error> where F: Handler, - >::Error: fmt::Debug, + >::Error: fmt::Display, A: for<'de> Deserialize<'de>, B: Serialize, { @@ -194,7 +195,7 @@ async fn run_inner( ) -> Result<(), Error> where F: Handler, - >::Error: fmt::Debug, + >::Error: fmt::Display, A: for<'de> Deserialize<'de>, B: Serialize, { @@ -213,14 +214,17 @@ where let req = match f.await { Ok(res) => EventCompletionRequest { request_id, body: res }.into_req()?, - Err(e) => EventErrorRequest { - request_id, - diagnostic: Diagnostic { - error_message: format!("{:?}", e), - error_type: type_name_of_val(e).to_owned(), - }, + Err(e) => { + error!("{}", e); + EventErrorRequest { + request_id, + diagnostic: Diagnostic { + error_message: format!("{}", e), + error_type: type_name_of_val(e).to_owned(), + }, + } + .into_req()? } - .into_req()?, }; client.call(req).await?; } @@ -228,6 +232,11 @@ where Ok(()) } +/// Returns the name of as a slice, but it is always the same +/// value for all errors: +/// ``` +/// "alloc::boxed::Box" +/// ``` fn type_name_of_val(_: T) -> &'static str { std::any::type_name::() } From afb2b79bba087fefd519590f0a0c9e730acfb54b Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 22 Jul 2020 10:05:38 +0000 Subject: [PATCH 08/30] Added basic.rs example, comments to other examples --- Cargo.lock | 1 + lambda/Cargo.toml | 1 + lambda/examples/basic.rs | 57 +++++++++++++++++++++++++++++++++++++++ lambda/examples/hello.rs | 4 +++ lambda/examples/readme.md | 2 +- 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 lambda/examples/basic.rs diff --git a/Cargo.lock b/Cargo.lock index 329fd8fe..a0468d05 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -323,6 +323,7 @@ dependencies = [ "lambda-attributes 0.1.0", "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.56 (registry+https://github.com/rust-lang/crates.io-index)", "simple-error 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "simple_logger 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/lambda/Cargo.toml b/lambda/Cargo.toml index 5e504c85..10d33266 100644 --- a/lambda/Cargo.toml +++ b/lambda/Cargo.toml @@ -27,3 +27,4 @@ log = "0.4" # used in some of the examples simple-error = "0.2" simple_logger = "1.6" +serde_derive = "1.0" diff --git a/lambda/examples/basic.rs b/lambda/examples/basic.rs new file mode 100644 index 00000000..e132b53f --- /dev/null +++ b/lambda/examples/basic.rs @@ -0,0 +1,57 @@ +use lambda::{handler_fn, Context}; +use serde::{Deserialize, Serialize}; +use serde_json::{json, Value}; +use simple_logger; + +/// A shorthand for `Box` +/// type required by aws-lambda-rust-runtime. +pub type Error = Box; + +#[tokio::main] +async fn main() -> Result<(), Error> { + // required to enable CloudWatch error logging by the runtime + // can be replaced with any other method of initializing `log` + simple_logger::init_with_level(log::Level::Info)?; + + let func = handler_fn(my_handler); + lambda::run(func).await?; + Ok(()) +} + +pub(crate) async fn my_handler(event: Value, ctx: Context) -> Result { + // extract some useful info from the request + let command = match serde_json::from_value::(event) { + Err(e) => { + return Err(Box::new(e)); + } + Ok(v) => v.command, + }; + + // prepare the response + let resp = Response { + req_id: ctx.request_id, + msg: format!("Command {} executed.", command), + }; + + // return `Response` as JSON + Ok(json!(resp)) +} + +/// This is a made up example of what a response structure may look like. +/// There is no restriction on what it can be. The runtime requires responses +/// to be serialized into `serde_json::Value`. The runtime pays no attention +/// to the contents of the response payload. +#[derive(Serialize)] +struct Response { + req_id: String, + msg: String, +} + +/// This is also a made up example. Requests come into the runtime as unicode +/// strings and are converted into `serde_json::Value`, which can map to your +/// own structures. The runtime pays no attention to the +/// contents of the request payload. +#[derive(Deserialize)] +struct Request { + command: String, +} diff --git a/lambda/examples/hello.rs b/lambda/examples/hello.rs index 99472874..090ab34d 100644 --- a/lambda/examples/hello.rs +++ b/lambda/examples/hello.rs @@ -8,3 +8,7 @@ type Error = Box; async fn main(event: Value, _: Context) -> Result { Ok(event) } + +// #[lambda] attribute removes the need for boilerplate code +// required by `lambda::run(func).await?` demonstrated in other +// examples. diff --git a/lambda/examples/readme.md b/lambda/examples/readme.md index 43094e22..4074f366 100644 --- a/lambda/examples/readme.md +++ b/lambda/examples/readme.md @@ -12,7 +12,7 @@ cp ./target/x86_64-unknown-linux-musl/release/examples/error-handling ./bootstra ``` 3. Upload to AWS Lambda ``` -aws lambda update-function-code --region us-east-1 --function-name ReturnValue --zip-file fileb://lambda.zip +aws lambda update-function-code --region us-east-1 --function-name RuntimeTest --zip-file fileb://lambda.zip ``` _Remember to replace the names and IDs with your own values._ From 64fcfc2223e1d9bf508d115ba9dd909dfaef757d Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 22 Jul 2020 10:46:32 +0000 Subject: [PATCH 09/30] Tidied up examples readme. --- lambda/examples/readme.md | 99 ++++++++++++++++++++++++++++++++++----- 1 file changed, 86 insertions(+), 13 deletions(-) diff --git a/lambda/examples/readme.md b/lambda/examples/readme.md index 4074f366..773a5f1c 100644 --- a/lambda/examples/readme.md +++ b/lambda/examples/readme.md @@ -1,25 +1,92 @@ ## How to compile and run the examples -1. Compile the example you want to run +1. Create a Lambda function called _RuntimeTest_ in AWS with a custom runtime and no code. + +2. Compile all examples ``` -cargo build --release --target x86_64-unknown-linux-musl --example error-handling +cargo build --release --target x86_64-unknown-linux-musl --examples ``` -2. Prepare the package +3. Prepare the package for the example you want to test, e.g. ``` -cp ./target/x86_64-unknown-linux-musl/release/examples/error-handling ./bootstrap && zip lambda.zip bootstrap && rm bootstrap +cp ./target/x86_64-unknown-linux-musl/release/examples/hello ./bootstrap && zip lambda.zip bootstrap && rm bootstrap +``` +4. Upload the package to AWS Lambda +``` +aws lambda update-function-code --region us-east-1 --function-name RuntimeTest --zip-file fileb://lambda.zip +``` +_Feel free to replace the names and IDs with your own values._ + +## basic.rs + +**Deployment**: +```bash +cp ./target/x86_64-unknown-linux-musl/release/examples/basic ./bootstrap && zip lambda.zip bootstrap && rm bootstrap +aws lambda update-function-code --region us-east-1 --function-name RuntimeTest --zip-file fileb://lambda.zip +``` + +**Test event JSON (success)**: +```json +{ "command": "do something" } ``` -3. Upload to AWS Lambda + +Sample response: +```json +{ + "msg": "Command do something executed.", + "req_id": "67a038e4-dc19-4adf-aa32-5ba09312c6ca" +} +``` + +**Test event JSON (error)**: +```json +{ "foo": "do something" } +``` + +Sample response: +```json +{ + "errorType": "alloc::boxed::Box", + "errorMessage": "missing field `command`" +} ``` + +## hello.rs + +The most basic example using `#[lambda]` macro to reduce the amount of boilerplate code. + +**Deployment**: +```bash +cp ./target/x86_64-unknown-linux-musl/release/examples/hello ./bootstrap && zip lambda.zip bootstrap && rm bootstrap aws lambda update-function-code --region us-east-1 --function-name RuntimeTest --zip-file fileb://lambda.zip ``` -_Remember to replace the names and IDs with your own values._ +**Test event JSON**: +```json +{ "foo": "bar" } +``` + +Sample response: +```json +{ + "foo": "bar" +} +``` + +## hello-without-macro.rs -## Error handling examples for aws-lambda-rust-runtime +The same as hello.rs example, but without `#[lambda]` macro to allow for more control at a lower level. -#### Error logging by the runtime +**Deployment**: +```bash +cp ./target/x86_64-unknown-linux-musl/release/examples/hello-without-macro ./bootstrap && zip lambda.zip bootstrap && rm bootstrap +aws lambda update-function-code --region us-east-1 --function-name RuntimeTest --zip-file fileb://lambda.zip +``` + +The test event JSON and the sample response are identical to that of _hello.rs_ example. + +## error-handling Errors are logged by the runtime only if `log` is initialised by the handler. These examples use `simple_logger`, but you can use any other provider that works with `log`. @@ -27,11 +94,17 @@ These examples use `simple_logger`, but you can use any other provider that work simple_logger::init_with_level(log::Level::Debug)?; ``` +**Deployment**: +```bash +cp ./target/x86_64-unknown-linux-musl/release/examples/error-handling ./bootstrap && zip lambda.zip bootstrap && rm bootstrap +aws lambda update-function-code --region us-east-1 --function-name RuntimeTest --zip-file fileb://lambda.zip +``` + #### Sample log output The following input/output examples correspond to different `match` arms in the handler of `error-handling.rs`. -### Invalid JSON input +### Invalid event JSON Test input: ```json @@ -58,7 +131,7 @@ REPORT RequestId: b98e07c6-e2ba-4ca6-9968-d0b94729ddba Duration: 2.06 ms Billed ### A simple text-only error -Test input: +Test event JSON: ```json { "event_type": "SimpleError" @@ -83,7 +156,7 @@ REPORT RequestId: 77c66dbf-bd60-4f77-8453-682d0bceba91 Duration: 0.98 ms Billed ### A custom error with JSON output for Display trait -Test input: +Test event JSON: ```json { "event_type": "CustomError" @@ -108,7 +181,7 @@ REPORT RequestId: b46b0588-1383-4224-bc7a-42b0d61930c1 Duration: 0.91 ms Billed ### A 3rd party error from _std::fs::File::open_ -Test input: +Test event JSON: ```json { "event_type": "ExternalError" @@ -133,7 +206,7 @@ REPORT RequestId: 893d24e5-cb79-4f6f-bae0-36304c62e9da Duration: 1.15 ms Billed ### A response to a successful Lambda execution -Test input: +Test event JSON: ```json { "event_type": "Response" From 96a90afb462e0a7fdcf570141b92b0b6d702db10 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 22 Jul 2020 10:51:16 +0000 Subject: [PATCH 10/30] Fixed headers in examples readme. --- lambda/examples/readme.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lambda/examples/readme.md b/lambda/examples/readme.md index 773a5f1c..fd69ba9d 100644 --- a/lambda/examples/readme.md +++ b/lambda/examples/readme.md @@ -100,11 +100,9 @@ cp ./target/x86_64-unknown-linux-musl/release/examples/error-handling ./bootstra aws lambda update-function-code --region us-east-1 --function-name RuntimeTest --zip-file fileb://lambda.zip ``` -#### Sample log output - The following input/output examples correspond to different `match` arms in the handler of `error-handling.rs`. -### Invalid event JSON +#### Invalid event JSON Test input: ```json @@ -129,7 +127,7 @@ END RequestId: b98e07c6-e2ba-4ca6-9968-d0b94729ddba REPORT RequestId: b98e07c6-e2ba-4ca6-9968-d0b94729ddba Duration: 2.06 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 28 MB Init Duration: 33.67 ms ``` -### A simple text-only error +#### A simple text-only error Test event JSON: ```json @@ -154,7 +152,7 @@ END RequestId: 77c66dbf-bd60-4f77-8453-682d0bceba91 REPORT RequestId: 77c66dbf-bd60-4f77-8453-682d0bceba91 Duration: 0.98 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 28 MB ``` -### A custom error with JSON output for Display trait +#### A custom error with JSON output for Display trait Test event JSON: ```json @@ -179,7 +177,7 @@ END RequestId: b46b0588-1383-4224-bc7a-42b0d61930c1 REPORT RequestId: b46b0588-1383-4224-bc7a-42b0d61930c1 Duration: 0.91 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 29 MB ``` -### A 3rd party error from _std::fs::File::open_ +#### A 3rd party error from _std::fs::File::open_ Test event JSON: ```json @@ -204,7 +202,7 @@ END RequestId: 893d24e5-cb79-4f6f-bae0-36304c62e9da REPORT RequestId: 893d24e5-cb79-4f6f-bae0-36304c62e9da Duration: 1.15 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 29 MB ``` -### A response to a successful Lambda execution +#### A response to a successful Lambda execution Test event JSON: ```json From 5d07f3f975fb8b4efe97de0b61f298652c7e0a0f Mon Sep 17 00:00:00 2001 From: rimutaka Date: Wed, 22 Jul 2020 11:11:25 +0000 Subject: [PATCH 11/30] Formatting fix in error-handling.rs. --- lambda/examples/error-handling.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lambda/examples/error-handling.rs b/lambda/examples/error-handling.rs index 2e2799ea..3107eab6 100644 --- a/lambda/examples/error-handling.rs +++ b/lambda/examples/error-handling.rs @@ -2,11 +2,10 @@ use lambda::handler_fn; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; -use simple_logger; use simple_error; +use simple_logger; use std::fs::File; - /// A shorthand for `Box` type required by aws-lambda-rust-runtime. pub type Error = Box; @@ -54,9 +53,7 @@ pub(crate) async fn func(event: Value, ctx: lambda::Context) -> Result { // generate a simple text message error using `simple_error` crate - return Err(Box::new(simple_error::SimpleError::new( - "A simple error as requested!", - ))); + return Err(Box::new(simple_error::SimpleError::new("A simple error as requested!"))); } Ok(v) if v.event_type == EventType::CustomError => { // generate a custom error using our own structure From 82d235195d053601e9a9a9d26abeef66e4e37a47 Mon Sep 17 00:00:00 2001 From: rimutaka Date: Wed, 22 Jul 2020 11:22:10 +0000 Subject: [PATCH 12/30] Fixed comment in lib.rs --- lambda/src/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lambda/src/lib.rs b/lambda/src/lib.rs index e3e8d102..6b315879 100644 --- a/lambda/src/lib.rs +++ b/lambda/src/lib.rs @@ -232,11 +232,8 @@ where Ok(()) } -/// Returns the name of as a slice, but it is always the same -/// value for all errors: -/// ``` -/// "alloc::boxed::Box" -/// ``` +/// Returns the name of as a slice, but the value is +/// the same for all errors because the type is the same. fn type_name_of_val(_: T) -> &'static str { std::any::type_name::() } From 5f63aa952a4e22b386f657620e06b7c7d410f5b3 Mon Sep 17 00:00:00 2001 From: mx Date: Thu, 23 Jul 2020 12:53:39 +1200 Subject: [PATCH 13/30] Corrected handler_fn interface misconception in basic.rs Co-authored-by: Veetaha --- lambda/examples/basic.rs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/lambda/examples/basic.rs b/lambda/examples/basic.rs index e132b53f..616d0a52 100644 --- a/lambda/examples/basic.rs +++ b/lambda/examples/basic.rs @@ -18,14 +18,9 @@ async fn main() -> Result<(), Error> { Ok(()) } -pub(crate) async fn my_handler(event: Value, ctx: Context) -> Result { +pub(crate) async fn my_handler(event: Request, ctx: Context) -> Result { // extract some useful info from the request - let command = match serde_json::from_value::(event) { - Err(e) => { - return Err(Box::new(e)); - } - Ok(v) => v.command, - }; + let command = event.command; // prepare the response let resp = Response { @@ -33,13 +28,13 @@ pub(crate) async fn my_handler(event: Value, ctx: Context) -> Result Date: Thu, 23 Jul 2020 01:20:45 +0000 Subject: [PATCH 14/30] Upper-cased and edited examples/readme.md --- lambda/examples/{readme.md => README.md} | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) rename lambda/examples/{readme.md => README.md} (93%) diff --git a/lambda/examples/readme.md b/lambda/examples/README.md similarity index 93% rename from lambda/examples/readme.md rename to lambda/examples/README.md index fd69ba9d..7ecbbb50 100644 --- a/lambda/examples/readme.md +++ b/lambda/examples/README.md @@ -47,10 +47,11 @@ Sample response: Sample response: ```json { - "errorType": "alloc::boxed::Box", - "errorMessage": "missing field `command`" + "errorType": "Runtime.ExitError", + "errorMessage": "RequestId: 586366df-f271-4e6e-9c30-b3dcab30f4e8 Error: Runtime exited with error: exit status 1" } ``` +The runtime could not deserialize our invalid input, but it did not give a detailed explanation why the error occurred. See _error-handling.rs_ example for more error handling options. ## hello.rs @@ -86,9 +87,9 @@ aws lambda update-function-code --region us-east-1 --function-name RuntimeTest - The test event JSON and the sample response are identical to that of _hello.rs_ example. -## error-handling +## error-handling.rs -Errors are logged by the runtime only if `log` is initialised by the handler. +Errors are logged by the runtime only if `log` is initialized by the handler. These examples use `simple_logger`, but you can use any other provider that works with `log`. ``` simple_logger::init_with_level(log::Level::Debug)?; From 878788cd94b1512a1123f8f90869c5bad309387d Mon Sep 17 00:00:00 2001 From: David Barsky Date: Wed, 22 Jul 2020 21:52:19 -0400 Subject: [PATCH 15/30] Add log and tracing examples; fix `tracing` dependency features. --- lambda/Cargo.toml | 4 ++++ ...ut-macro.rs => hello-without-macro-log.rs} | 4 ++++ .../examples/hello-without-macro-tracing.rs | 24 +++++++++++++++++++ 3 files changed, 32 insertions(+) rename lambda/examples/{hello-without-macro.rs => hello-without-macro-log.rs} (81%) create mode 100644 lambda/examples/hello-without-macro-tracing.rs diff --git a/lambda/Cargo.toml b/lambda/Cargo.toml index 60fb5b47..796efec8 100644 --- a/lambda/Cargo.toml +++ b/lambda/Cargo.toml @@ -23,7 +23,11 @@ tower-service = "0.3" bytes = "0.5" http = "0.2" lambda-attributes = { path = "../lambda-attributes", version = "0.1.0", optional = true} +tracing = { version = "0.1", features = ["log"] } +tracing-futures = "0.2" async-stream = "0.2" [dev-dependencies] +tracing-subscriber = "0.2" once_cell = "1.4.0" +simple_logger = "1.6.0" diff --git a/lambda/examples/hello-without-macro.rs b/lambda/examples/hello-without-macro-log.rs similarity index 81% rename from lambda/examples/hello-without-macro.rs rename to lambda/examples/hello-without-macro-log.rs index 2aec334f..a2059b8c 100644 --- a/lambda/examples/hello-without-macro.rs +++ b/lambda/examples/hello-without-macro-log.rs @@ -1,11 +1,15 @@ use lambda::{handler_fn, Context}; use serde_json::Value; +use tracing::info; type Error = Box; #[tokio::main] async fn main() -> Result<(), Error> { let func = handler_fn(func); + simple_logger::init().unwrap(); + + info!("Hello!"); lambda::run(func).await?; Ok(()) } diff --git a/lambda/examples/hello-without-macro-tracing.rs b/lambda/examples/hello-without-macro-tracing.rs new file mode 100644 index 00000000..dde4d94f --- /dev/null +++ b/lambda/examples/hello-without-macro-tracing.rs @@ -0,0 +1,24 @@ +use lambda::{handler_fn, Context}; +use serde_json::Value; +use tracing::info; + +type Error = Box; + +#[tokio::main] +async fn main() -> Result<(), Error> { + let func = handler_fn(func); + tracing_subscriber::fmt() + .with_max_level(tracing::Level::INFO) + // this needs to be set to false, otherwise ANSI color codes will + // show up in a confusing manner in CloudWatch logs. + .with_ansi(false) + .init(); + + info!("Hello!"); + lambda::run(func).await?; + Ok(()) +} + +async fn func(event: Value, _: Context) -> Result { + Ok(event) +} From f03d2b554de0935a7d2dad0a7ae58de12f3180ae Mon Sep 17 00:00:00 2001 From: David Barsky Date: Wed, 22 Jul 2020 22:48:33 -0400 Subject: [PATCH 16/30] disable time on `tracing_subscriber` --- lambda/examples/hello-without-macro-tracing.rs | 4 +++- lambda/src/lib.rs | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lambda/examples/hello-without-macro-tracing.rs b/lambda/examples/hello-without-macro-tracing.rs index dde4d94f..8d46a853 100644 --- a/lambda/examples/hello-without-macro-tracing.rs +++ b/lambda/examples/hello-without-macro-tracing.rs @@ -8,10 +8,12 @@ type Error = Box; async fn main() -> Result<(), Error> { let func = handler_fn(func); tracing_subscriber::fmt() - .with_max_level(tracing::Level::INFO) + .with_max_level(tracing::Level::TRACE) // this needs to be set to false, otherwise ANSI color codes will // show up in a confusing manner in CloudWatch logs. .with_ansi(false) + // disabling time is handy because CloudWatch will add the ingestion time. + .without_time() .init(); info!("Hello!"); diff --git a/lambda/src/lib.rs b/lambda/src/lib.rs index cff12c30..0dadbf74 100644 --- a/lambda/src/lib.rs +++ b/lambda/src/lib.rs @@ -55,6 +55,7 @@ use tokio::{ stream::{Stream, StreamExt}, }; use tower_service::Service; +use tracing::trace; mod client; mod requests; @@ -320,6 +321,7 @@ where A: for<'de> Deserialize<'de> + Send + Sync + 'static, B: Serialize + Send + Sync + 'static, { + trace!("Loading config from env"); let config = Config::from_env()?; let uri = config.endpoint.try_into().expect("Unable to convert to URL"); let runtime = Runtime::builder() From 6d369a513bd260ac4199f323247c5b397490c85b Mon Sep 17 00:00:00 2001 From: rimutaka Date: Thu, 23 Jul 2020 03:21:18 +0000 Subject: [PATCH 17/30] Removed unused refs from basic.rs --- lambda/examples/basic.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/lambda/examples/basic.rs b/lambda/examples/basic.rs index 616d0a52..de61b6f9 100644 --- a/lambda/examples/basic.rs +++ b/lambda/examples/basic.rs @@ -1,6 +1,5 @@ use lambda::{handler_fn, Context}; use serde::{Deserialize, Serialize}; -use serde_json::{json, Value}; use simple_logger; /// A shorthand for `Box` From ad25ed7154c9c98ddc4437a7a12415ace2ecc0bd Mon Sep 17 00:00:00 2001 From: rimutaka Date: Thu, 23 Jul 2020 23:47:12 +0000 Subject: [PATCH 18/30] Added error handling for #241, interim, broken. --- lambda/Cargo.toml | 2 + lambda/examples/README.md | 250 ++++++++++++++++++ lambda/examples/basic.rs | 50 ++++ lambda/examples/error-handling.rs | 107 ++++++++ lambda/examples/hello-without-macro-log.rs | 3 +- .../examples/hello-without-macro-tracing.rs | 3 +- lambda/src/lib.rs | 8 +- 7 files changed, 417 insertions(+), 6 deletions(-) create mode 100644 lambda/examples/README.md create mode 100644 lambda/examples/basic.rs create mode 100644 lambda/examples/error-handling.rs diff --git a/lambda/Cargo.toml b/lambda/Cargo.toml index 796efec8..f8322171 100644 --- a/lambda/Cargo.toml +++ b/lambda/Cargo.toml @@ -31,3 +31,5 @@ async-stream = "0.2" tracing-subscriber = "0.2" once_cell = "1.4.0" simple_logger = "1.6.0" +log = "0.4" +simple-error = "0.2" diff --git a/lambda/examples/README.md b/lambda/examples/README.md new file mode 100644 index 00000000..7faee362 --- /dev/null +++ b/lambda/examples/README.md @@ -0,0 +1,250 @@ + +## How to compile and run the examples + +1. Create a Lambda function called _RuntimeTest_ in AWS with a custom runtime and no code. + +2. Compile all examples + +``` +cargo build --release --target x86_64-unknown-linux-musl --examples +``` +3. Prepare the package for the example you want to test, e.g. +``` +cp ./target/x86_64-unknown-linux-musl/release/examples/hello ./bootstrap && zip lambda.zip bootstrap && rm bootstrap +``` +4. Upload the package to AWS Lambda +``` +aws lambda update-function-code --region us-east-1 --function-name RuntimeTest --zip-file fileb://lambda.zip +``` +_Feel free to replace the names and IDs with your own values._ + +## basic.rs + +**Deployment**: +```bash +cp ./target/x86_64-unknown-linux-musl/release/examples/basic ./bootstrap && zip lambda.zip bootstrap && rm bootstrap +aws lambda update-function-code --region us-east-1 --function-name RuntimeTest --zip-file fileb://lambda.zip +``` + +**Test event JSON (success)**: +```json +{ "command": "do something" } +``` + +Sample response: +```json +{ + "msg": "Command do something executed.", + "req_id": "67a038e4-dc19-4adf-aa32-5ba09312c6ca" +} +``` + +**Test event JSON (error)**: +```json +{ "foo": "do something" } +``` + +Sample response: +```json +{ + "errorType": "Runtime.ExitError", + "errorMessage": "RequestId: 586366df-f271-4e6e-9c30-b3dcab30f4e8 Error: Runtime exited with error: exit status 1" +} +``` +The runtime could not deserialize our invalid input, but it did not give a detailed explanation why the error occurred in the response. More details appear in the CloudWatch log: +``` +START RequestId: 6e667f61-c5d4-4b07-a60f-cd1ab339c35f Version: $LATEST +Error: Error("missing field `command`", line: 1, column: 22) +END RequestId: 6e667f61-c5d4-4b07-a60f-cd1ab339c35f +REPORT RequestId: 6e667f61-c5d4-4b07-a60f-cd1ab339c35f Duration: 36.34 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 10 MB +RequestId: 6e667f61-c5d4-4b07-a60f-cd1ab339c35f Error: Runtime exited with error: exit status 1 +Runtime.ExitError +``` + + See _error-handling.rs_ example for more error handling options. + +## hello.rs + +The most basic example using `#[lambda]` macro to reduce the amount of boilerplate code. + +**Deployment**: +```bash +cp ./target/x86_64-unknown-linux-musl/release/examples/hello ./bootstrap && zip lambda.zip bootstrap && rm bootstrap +aws lambda update-function-code --region us-east-1 --function-name RuntimeTest --zip-file fileb://lambda.zip +``` + +**Test event JSON**: +```json +{ "foo": "bar" } +``` + +Sample response: +```json +{ + "foo": "bar" +} +``` + +## hello-without-macro-tracing.rs + +The same as hello.rs example, but without `#[lambda]` macro to allow for more control at a lower level. + +**Deployment**: +```bash +cp ./target/x86_64-unknown-linux-musl/release/examples/hello-without-macro-tracing ./bootstrap && zip lambda.zip bootstrap && rm bootstrap +aws lambda update-function-code --region us-east-1 --function-name RuntimeTest --zip-file fileb://lambda.zip +``` + +## hello-without-macro-log.rs + +The same as hello.rs example, but without `#[lambda]` macro to allow for more control at a lower level. + +**Deployment**: +```bash +cp ./target/x86_64-unknown-linux-musl/release/examples/hello-without-macro-log ./bootstrap && zip lambda.zip bootstrap && rm bootstrap +aws lambda update-function-code --region us-east-1 --function-name RuntimeTest --zip-file fileb://lambda.zip +``` + + + +The test event JSON and the sample response are identical to that of _hello.rs_ example. + +## error-handling.rs + +Errors are logged by the runtime only if `log` is initialized by the handler. +These examples use `simple_logger`, but you can use any other provider that works with `log`. +``` +simple_logger::init_with_level(log::Level::Debug)?; +``` + +**Deployment**: +```bash +cp ./target/x86_64-unknown-linux-musl/release/examples/error-handling ./bootstrap && zip lambda.zip bootstrap && rm bootstrap +aws lambda update-function-code --region us-east-1 --function-name RuntimeTest --zip-file fileb://lambda.zip +``` + +The following input/output examples correspond to different `match` arms in the handler of `error-handling.rs`. + +#### Invalid event JSON + +Test input: +```json +{ + "event_type": "WrongType" +} +``` + +Lambda output: +``` +{ + "errorType": "alloc::boxed::Box", + "errorMessage": "unknown variant `WrongType`, expected one of `Response`, `ExternalError`, `SimpleError`, `CustomError`" +} +``` + +CloudWatch records: +``` +START RequestId: b98e07c6-e2ba-4ca6-9968-d0b94729ddba Version: $LATEST +2020-07-21 04:28:52,630 ERROR [lambda] unknown variant `WrongType`, expected one of `Response`, `ExternalError`, `SimpleError`, `CustomError` +END RequestId: b98e07c6-e2ba-4ca6-9968-d0b94729ddba +REPORT RequestId: b98e07c6-e2ba-4ca6-9968-d0b94729ddba Duration: 2.06 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 28 MB Init Duration: 33.67 ms +``` + +#### A simple text-only error + +Test event JSON: +```json +{ + "event_type": "SimpleError" +} +``` + +Lambda output: +``` +{ + "errorType": "alloc::boxed::Box", + "errorMessage": "A simple error as requested!" +} +``` + +CloudWatch records: +``` +START RequestId: 77c66dbf-bd60-4f77-8453-682d0bceba91 Version: $LATEST +2020-07-21 04:35:28,044 ERROR [lambda] A simple error as requested! +END RequestId: 77c66dbf-bd60-4f77-8453-682d0bceba91 +REPORT RequestId: 77c66dbf-bd60-4f77-8453-682d0bceba91 Duration: 0.98 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 28 MB +``` + +#### A custom error with JSON output for Display trait + +Test event JSON: +```json +{ + "event_type": "CustomError" +} +``` + +Lambda output: +``` +{ + "errorType": "alloc::boxed::Box", + "errorMessage": "{\"is_authenticated\":false,\"msg\":\"A custom error as requested!\",\"req_id\":\"b46b0588-1383-4224-bc7a-42b0d61930c1\"}" +} +``` + +CloudWatch records: +``` +START RequestId: b46b0588-1383-4224-bc7a-42b0d61930c1 Version: $LATEST +2020-07-21 04:39:00,133 ERROR [lambda] {"is_authenticated":false,"msg":"A custom error as requested!","req_id":"b46b0588-1383-4224-bc7a-42b0d61930c1"} +END RequestId: b46b0588-1383-4224-bc7a-42b0d61930c1 +REPORT RequestId: b46b0588-1383-4224-bc7a-42b0d61930c1 Duration: 0.91 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 29 MB +``` + +#### A 3rd party error from _std::fs::File::open_ + +Test event JSON: +```json +{ + "event_type": "ExternalError" +} +``` + +Lambda output: +``` +{ + "errorType": "alloc::boxed::Box", + "errorMessage": "No such file or directory (os error 2)" +} +``` + +CloudWatch records: +``` +START RequestId: 893d24e5-cb79-4f6f-bae0-36304c62e9da Version: $LATEST +2020-07-21 04:43:56,254 ERROR [lambda] No such file or directory (os error 2) +END RequestId: 893d24e5-cb79-4f6f-bae0-36304c62e9da +REPORT RequestId: 893d24e5-cb79-4f6f-bae0-36304c62e9da Duration: 1.15 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 29 MB +``` + +#### A response to a successful Lambda execution + +Test event JSON: +```json +{ + "event_type": "Response" +} +``` + +Lambda output: +``` +{ + "msg": "OK", + "req_id": "9752a3ad-6566-44e4-aafd-74db1fd4f361" +} +``` + +CloudWatch records: +``` +START RequestId: 9752a3ad-6566-44e4-aafd-74db1fd4f361 Version: $LATEST +END RequestId: 9752a3ad-6566-44e4-aafd-74db1fd4f361 +REPORT RequestId: 9752a3ad-6566-44e4-aafd-74db1fd4f361 Duration: 0.89 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 29 MB +``` \ No newline at end of file diff --git a/lambda/examples/basic.rs b/lambda/examples/basic.rs new file mode 100644 index 00000000..de61b6f9 --- /dev/null +++ b/lambda/examples/basic.rs @@ -0,0 +1,50 @@ +use lambda::{handler_fn, Context}; +use serde::{Deserialize, Serialize}; +use simple_logger; + +/// A shorthand for `Box` +/// type required by aws-lambda-rust-runtime. +pub type Error = Box; + +#[tokio::main] +async fn main() -> Result<(), Error> { + // required to enable CloudWatch error logging by the runtime + // can be replaced with any other method of initializing `log` + simple_logger::init_with_level(log::Level::Info)?; + + let func = handler_fn(my_handler); + lambda::run(func).await?; + Ok(()) +} + +pub(crate) async fn my_handler(event: Request, ctx: Context) -> Result { + // extract some useful info from the request + let command = event.command; + + // prepare the response + let resp = Response { + req_id: ctx.request_id, + msg: format!("Command {} executed.", command), + }; + + // return `Response` (it will be serialized to JSON automatically by the runtime) + Ok(resp) +} + +/// This is a made-up example of what a response structure may look like. +/// There is no restriction on what it can be. The runtime requires responses +/// to be serialized into json. The runtime pays no attention +/// to the contents of the response payload. +#[derive(Serialize)] +struct Response { + req_id: String, + msg: String, +} + +/// This is also a made-up example. Requests come into the runtime as unicode +/// strings in json format, which can map to any structure that implements `serde::Deserialize` +/// The runtime pays no attention to the contents of the request payload. +#[derive(Deserialize)] +struct Request { + command: String, +} diff --git a/lambda/examples/error-handling.rs b/lambda/examples/error-handling.rs new file mode 100644 index 00000000..3107eab6 --- /dev/null +++ b/lambda/examples/error-handling.rs @@ -0,0 +1,107 @@ +/// See https://github.com/awslabs/aws-lambda-rust-runtime for more info on Rust runtime for AWS Lambda +use lambda::handler_fn; +use serde::{Deserialize, Serialize}; +use serde_json::{json, Value}; +use simple_error; +use simple_logger; +use std::fs::File; + +/// A shorthand for `Box` type required by aws-lambda-rust-runtime. +pub type Error = Box; + +#[derive(Debug, Serialize)] +struct CustomError { + is_authenticated: bool, + req_id: String, + msg: String, +} + +impl std::error::Error for CustomError { + // this implementation required `Debug` and `Display` traits +} + +impl std::fmt::Display for CustomError { + /// Display the error struct as a JSON string + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let err_as_json = json!(self).to_string(); + write!(f, "{}", err_as_json) + } +} + +/// The entry point called by aws-lambda-rust-runtime client for every new Lambda request. +#[tokio::main] +async fn main() -> Result<(), Error> { + simple_logger::init_with_level(log::Level::Debug)?; // Note, this can only be called once! + + // call the actual handler of the request + let func = handler_fn(func); + lambda::run(func).await?; + Ok(()) +} + +/// The actual handler of the Lambda request. +pub(crate) async fn func(event: Value, ctx: lambda::Context) -> Result { + // convert the JSON request to a struct + let req = serde_json::from_value::(event); + + // check if the conversion succeeded and what action was requested + match req { + Err(e) => { + // conversion from JSON to `Request` struct failed + // return serde_json error + return Err(Box::new(e)); + } + Ok(v) if v.event_type == EventType::SimpleError => { + // generate a simple text message error using `simple_error` crate + return Err(Box::new(simple_error::SimpleError::new("A simple error as requested!"))); + } + Ok(v) if v.event_type == EventType::CustomError => { + // generate a custom error using our own structure + let cust_err = CustomError { + is_authenticated: ctx.identity.is_some(), + req_id: ctx.request_id, + msg: "A custom error as requested!".into(), + }; + return Err(Box::new(cust_err)); + } + Ok(v) if v.event_type == EventType::ExternalError => { + // try to open a non-existent file to get an error and propagate it with `?` + let _file = File::open("non-existent-file.txt")?; + + // it should never execute past the above line + panic!(); + } + Ok(_) => { + // generate and return an OK response in JSON format + let resp = Response { + req_id: ctx.request_id, + msg: "OK".into(), + }; + + return Ok(json!(resp)); + } + } +} + +/// A simple Lambda response structure. +#[derive(Serialize)] +struct Response { + req_id: String, + msg: String, +} + +/// A simple Lambda request structure with just one field +/// that tells the Lambda what is expected of it. +#[derive(Deserialize)] +struct Request { + event_type: EventType, +} + +/// Event types that tell our Lambda what to do do. +#[derive(Deserialize, PartialEq)] +enum EventType { + Response, + ExternalError, + SimpleError, + CustomError, +} diff --git a/lambda/examples/hello-without-macro-log.rs b/lambda/examples/hello-without-macro-log.rs index a2059b8c..80598c14 100644 --- a/lambda/examples/hello-without-macro-log.rs +++ b/lambda/examples/hello-without-macro-log.rs @@ -15,5 +15,6 @@ async fn main() -> Result<(), Error> { } async fn func(event: Value, _: Context) -> Result { - Ok(event) + //Ok(event) + Err(simple_error::SimpleError::new("simple error").into()) } diff --git a/lambda/examples/hello-without-macro-tracing.rs b/lambda/examples/hello-without-macro-tracing.rs index 8d46a853..580b7197 100644 --- a/lambda/examples/hello-without-macro-tracing.rs +++ b/lambda/examples/hello-without-macro-tracing.rs @@ -22,5 +22,6 @@ async fn main() -> Result<(), Error> { } async fn func(event: Value, _: Context) -> Result { - Ok(event) + //Ok(event) + Err(simple_error::SimpleError::new("simple error").into()) } diff --git a/lambda/src/lib.rs b/lambda/src/lib.rs index 0dadbf74..0a0c335a 100644 --- a/lambda/src/lib.rs +++ b/lambda/src/lib.rs @@ -131,7 +131,7 @@ impl Handler for HandlerFn where F: Fn(A, Context) -> Fut, Fut: Future> + Send + Sync, - Error: Into> + fmt::Debug, + Error: Into> + fmt::Display, { type Error = Error; type Fut = Fut; @@ -174,7 +174,7 @@ where where F: Handler + Send + Sync + 'static, >::Fut: Future>::Error>> + Send + Sync + 'static, - >::Error: fmt::Debug + Send + Sync + 'static, + >::Error: fmt::Display + Send + Sync + 'static, A: for<'de> Deserialize<'de> + Send + Sync + 'static, B: Serialize + Send + Sync + 'static, { @@ -204,7 +204,7 @@ where request_id, diagnostic: Diagnostic { error_type: type_name_of_val(&err).to_owned(), - error_message: format!("{:?}", err), + error_message: format!("{}", err), }, } .into_req(), @@ -317,7 +317,7 @@ pub async fn run(handler: F) -> Result<(), Error> where F: Handler + Send + Sync + 'static, >::Fut: Future>::Error>> + Send + Sync + 'static, - >::Error: fmt::Debug + Send + Sync + 'static, + >::Error: fmt::Display + Send + Sync + 'static, A: for<'de> Deserialize<'de> + Send + Sync + 'static, B: Serialize + Send + Sync + 'static, { From 59227cd1bd0016c01319a0dac8ced8c665837711 Mon Sep 17 00:00:00 2001 From: rimutaka Date: Sat, 25 Jul 2020 09:49:26 +0000 Subject: [PATCH 19/30] Added err logging to lib.rs, consolidated examples --- lambda/examples/README.md | 28 ++--------------- lambda/examples/basic.rs | 3 ++ lambda/examples/error-handling.rs | 22 ++++++++++---- lambda/examples/hello-without-macro-log.rs | 20 ------------- .../examples/hello-without-macro-tracing.rs | 27 ----------------- lambda/examples/{hello.rs => macro.rs} | 0 lambda/src/lib.rs | 30 +++++++++++-------- 7 files changed, 40 insertions(+), 90 deletions(-) delete mode 100644 lambda/examples/hello-without-macro-log.rs delete mode 100644 lambda/examples/hello-without-macro-tracing.rs rename lambda/examples/{hello.rs => macro.rs} (100%) diff --git a/lambda/examples/README.md b/lambda/examples/README.md index 7faee362..7f10f139 100644 --- a/lambda/examples/README.md +++ b/lambda/examples/README.md @@ -63,13 +63,13 @@ Runtime.ExitError See _error-handling.rs_ example for more error handling options. -## hello.rs +## macro.rs The most basic example using `#[lambda]` macro to reduce the amount of boilerplate code. **Deployment**: ```bash -cp ./target/x86_64-unknown-linux-musl/release/examples/hello ./bootstrap && zip lambda.zip bootstrap && rm bootstrap +cp ./target/x86_64-unknown-linux-musl/release/examples/macro ./bootstrap && zip lambda.zip bootstrap && rm bootstrap aws lambda update-function-code --region us-east-1 --function-name RuntimeTest --zip-file fileb://lambda.zip ``` @@ -85,30 +85,6 @@ Sample response: } ``` -## hello-without-macro-tracing.rs - -The same as hello.rs example, but without `#[lambda]` macro to allow for more control at a lower level. - -**Deployment**: -```bash -cp ./target/x86_64-unknown-linux-musl/release/examples/hello-without-macro-tracing ./bootstrap && zip lambda.zip bootstrap && rm bootstrap -aws lambda update-function-code --region us-east-1 --function-name RuntimeTest --zip-file fileb://lambda.zip -``` - -## hello-without-macro-log.rs - -The same as hello.rs example, but without `#[lambda]` macro to allow for more control at a lower level. - -**Deployment**: -```bash -cp ./target/x86_64-unknown-linux-musl/release/examples/hello-without-macro-log ./bootstrap && zip lambda.zip bootstrap && rm bootstrap -aws lambda update-function-code --region us-east-1 --function-name RuntimeTest --zip-file fileb://lambda.zip -``` - - - -The test event JSON and the sample response are identical to that of _hello.rs_ example. - ## error-handling.rs Errors are logged by the runtime only if `log` is initialized by the handler. diff --git a/lambda/examples/basic.rs b/lambda/examples/basic.rs index de61b6f9..77318999 100644 --- a/lambda/examples/basic.rs +++ b/lambda/examples/basic.rs @@ -1,3 +1,6 @@ +// This example requires the following input to succeed: +// { "command": "do something" } + use lambda::{handler_fn, Context}; use serde::{Deserialize, Serialize}; use simple_logger; diff --git a/lambda/examples/error-handling.rs b/lambda/examples/error-handling.rs index 3107eab6..08f43f75 100644 --- a/lambda/examples/error-handling.rs +++ b/lambda/examples/error-handling.rs @@ -2,8 +2,6 @@ use lambda::handler_fn; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; -use simple_error; -use simple_logger; use std::fs::File; /// A shorthand for `Box` type required by aws-lambda-rust-runtime. @@ -28,10 +26,24 @@ impl std::fmt::Display for CustomError { } } -/// The entry point called by aws-lambda-rust-runtime client for every new Lambda request. #[tokio::main] async fn main() -> Result<(), Error> { - simple_logger::init_with_level(log::Level::Debug)?; // Note, this can only be called once! + // The runtime logging can be enabled here by initializing `log` with `simple_logger` + // or another compatible crate. The runtime is using `tracing` internally. + // You can comment out the `simple_logger` init line and uncomment the following block to + // use `tracing` in the handler function. + // + simple_logger::init_with_level(log::Level::Info)?; + /* + tracing_subscriber::fmt() + .with_max_level(tracing::Level::INFO) + // this needs to be set to false, otherwise ANSI color codes will + // show up in a confusing manner in CloudWatch logs. + .with_ansi(false) + // disabling time is handy because CloudWatch will add the ingestion time. + .without_time() + .init(); + */ // call the actual handler of the request let func = handler_fn(func); @@ -69,7 +81,7 @@ pub(crate) async fn func(event: Value, ctx: lambda::Context) -> Result { // generate and return an OK response in JSON format diff --git a/lambda/examples/hello-without-macro-log.rs b/lambda/examples/hello-without-macro-log.rs deleted file mode 100644 index 80598c14..00000000 --- a/lambda/examples/hello-without-macro-log.rs +++ /dev/null @@ -1,20 +0,0 @@ -use lambda::{handler_fn, Context}; -use serde_json::Value; -use tracing::info; - -type Error = Box; - -#[tokio::main] -async fn main() -> Result<(), Error> { - let func = handler_fn(func); - simple_logger::init().unwrap(); - - info!("Hello!"); - lambda::run(func).await?; - Ok(()) -} - -async fn func(event: Value, _: Context) -> Result { - //Ok(event) - Err(simple_error::SimpleError::new("simple error").into()) -} diff --git a/lambda/examples/hello-without-macro-tracing.rs b/lambda/examples/hello-without-macro-tracing.rs deleted file mode 100644 index 580b7197..00000000 --- a/lambda/examples/hello-without-macro-tracing.rs +++ /dev/null @@ -1,27 +0,0 @@ -use lambda::{handler_fn, Context}; -use serde_json::Value; -use tracing::info; - -type Error = Box; - -#[tokio::main] -async fn main() -> Result<(), Error> { - let func = handler_fn(func); - tracing_subscriber::fmt() - .with_max_level(tracing::Level::TRACE) - // this needs to be set to false, otherwise ANSI color codes will - // show up in a confusing manner in CloudWatch logs. - .with_ansi(false) - // disabling time is handy because CloudWatch will add the ingestion time. - .without_time() - .init(); - - info!("Hello!"); - lambda::run(func).await?; - Ok(()) -} - -async fn func(event: Value, _: Context) -> Result { - //Ok(event) - Err(simple_error::SimpleError::new("simple error").into()) -} diff --git a/lambda/examples/hello.rs b/lambda/examples/macro.rs similarity index 100% rename from lambda/examples/hello.rs rename to lambda/examples/macro.rs diff --git a/lambda/src/lib.rs b/lambda/src/lib.rs index 0a0c335a..a4bebe2b 100644 --- a/lambda/src/lib.rs +++ b/lambda/src/lib.rs @@ -55,7 +55,7 @@ use tokio::{ stream::{Stream, StreamExt}, }; use tower_service::Service; -use tracing::trace; +use tracing::{error, trace}; mod client; mod requests; @@ -200,23 +200,29 @@ where body: response, } .into_req(), - Err(err) => EventErrorRequest { + Err(err) => { + error!("{}", err); // logs the error in CloudWatch + EventErrorRequest { + request_id, + diagnostic: Diagnostic { + error_type: type_name_of_val(&err).to_owned(), + error_message: format!("{}", err), // returns the error to the caller via Lambda API + }, + } + .into_req() + } + }, + Err(err) if err.is_panic() => { + error!("Lambda panicked!"); + EventErrorRequest { request_id, diagnostic: Diagnostic { error_type: type_name_of_val(&err).to_owned(), - error_message: format!("{}", err), + error_message: "Lambda panicked!".to_owned(), }, } - .into_req(), - }, - Err(err) if err.is_panic() => EventErrorRequest { - request_id, - diagnostic: Diagnostic { - error_type: type_name_of_val(&err).to_owned(), - error_message: "Lambda panicked!".to_owned(), - }, + .into_req() } - .into_req(), Err(_) => unreachable!("tokio::task should not be canceled"), }; let req = req?; From e40ea17b8627b84ae3503873ff34024cde0283f7 Mon Sep 17 00:00:00 2001 From: rimutaka Date: Sat, 25 Jul 2020 23:40:45 +0000 Subject: [PATCH 20/30] Log panic as Debug+Display, improved examples --- lambda/examples/README.md | 28 +++++++++++++ lambda/examples/basic.rs | 36 ++++++++-------- lambda/examples/error-handling.rs | 70 +++++++++++++++---------------- lambda/src/lib.rs | 4 +- 4 files changed, 81 insertions(+), 57 deletions(-) diff --git a/lambda/examples/README.md b/lambda/examples/README.md index 7f10f139..51a5a10b 100644 --- a/lambda/examples/README.md +++ b/lambda/examples/README.md @@ -201,6 +201,34 @@ END RequestId: 893d24e5-cb79-4f6f-bae0-36304c62e9da REPORT RequestId: 893d24e5-cb79-4f6f-bae0-36304c62e9da Duration: 1.15 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 29 MB ``` +#### Handler panic + +Test event JSON: +```json +{ + "event_type": "Panic" +} +``` + +Lambda output: +``` +{ + "errorType": "Runtime.ExitError", + "errorMessage": "RequestId: 2d579019-07f7-409a-a6e6-af7725253307 Error: Runtime exited with error: exit status 101" +} +``` + +CloudWatch records: +``` +START RequestId: 2d579019-07f7-409a-a6e6-af7725253307 Version: $LATEST +thread 'main' panicked at 'explicit panic', lambda/examples/error-handling.rs:87:13 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +END RequestId: 2d579019-07f7-409a-a6e6-af7725253307 +REPORT RequestId: 2d579019-07f7-409a-a6e6-af7725253307 Duration: 43.40 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 27 MB Init Duration: 23.15 ms +RequestId: 2d579019-07f7-409a-a6e6-af7725253307 Error: Runtime exited with error: exit status 101 +Runtime.ExitError +``` + #### A response to a successful Lambda execution Test event JSON: diff --git a/lambda/examples/basic.rs b/lambda/examples/basic.rs index 77318999..2d2ad02d 100644 --- a/lambda/examples/basic.rs +++ b/lambda/examples/basic.rs @@ -9,6 +9,24 @@ use simple_logger; /// type required by aws-lambda-rust-runtime. pub type Error = Box; +/// This is also a made-up example. Requests come into the runtime as unicode +/// strings in json format, which can map to any structure that implements `serde::Deserialize` +/// The runtime pays no attention to the contents of the request payload. +#[derive(Deserialize)] +struct Request { + command: String, +} + +/// This is a made-up example of what a response structure may look like. +/// There is no restriction on what it can be. The runtime requires responses +/// to be serialized into json. The runtime pays no attention +/// to the contents of the response payload. +#[derive(Serialize)] +struct Response { + req_id: String, + msg: String, +} + #[tokio::main] async fn main() -> Result<(), Error> { // required to enable CloudWatch error logging by the runtime @@ -33,21 +51,3 @@ pub(crate) async fn my_handler(event: Request, ctx: Context) -> Result` type required by aws-lambda-rust-runtime. pub type Error = Box; +/// A simple Lambda request structure with just one field +/// that tells the Lambda what is expected of it. +#[derive(Deserialize)] +struct Request { + event_type: EventType, +} + +/// Event types that tell our Lambda what to do do. +#[derive(Deserialize, PartialEq)] +enum EventType { + Response, + ExternalError, + SimpleError, + CustomError, + Panic, +} + +/// A simple Lambda response structure. +#[derive(Serialize)] +struct Response { + req_id: String, + msg: String, +} + #[derive(Debug, Serialize)] struct CustomError { is_authenticated: bool, @@ -53,21 +77,13 @@ async fn main() -> Result<(), Error> { /// The actual handler of the Lambda request. pub(crate) async fn func(event: Value, ctx: lambda::Context) -> Result { - // convert the JSON request to a struct - let req = serde_json::from_value::(event); - - // check if the conversion succeeded and what action was requested - match req { - Err(e) => { - // conversion from JSON to `Request` struct failed - // return serde_json error - return Err(Box::new(e)); - } - Ok(v) if v.event_type == EventType::SimpleError => { + // check what action was requested + match serde_json::from_value::(event)?.event_type { + EventType::SimpleError => { // generate a simple text message error using `simple_error` crate return Err(Box::new(simple_error::SimpleError::new("A simple error as requested!"))); } - Ok(v) if v.event_type == EventType::CustomError => { + EventType::CustomError => { // generate a custom error using our own structure let cust_err = CustomError { is_authenticated: ctx.identity.is_some(), @@ -76,14 +92,17 @@ pub(crate) async fn func(event: Value, ctx: lambda::Context) -> Result { + EventType::ExternalError => { // try to open a non-existent file to get an error and propagate it with `?` let _file = File::open("non-existent-file.txt")?; // it should never execute past the above line unreachable!(); } - Ok(_) => { + EventType::Panic => { + panic!(); + } + EventType::Response => { // generate and return an OK response in JSON format let resp = Response { req_id: ctx.request_id, @@ -94,26 +113,3 @@ pub(crate) async fn func(event: Value, ctx: lambda::Context) -> Result { - error!("Lambda panicked!"); + error!("{:?}", err); // inconsistent with other log record formats - to be reviewed EventErrorRequest { request_id, diagnostic: Diagnostic { error_type: type_name_of_val(&err).to_owned(), - error_message: "Lambda panicked!".to_owned(), + error_message: format!("Lambda panicked: {}", err), }, } .into_req() From e2ae1e56edc3c187198da39d46d20c4ff1db5adb Mon Sep 17 00:00:00 2001 From: rimutaka Date: Sat, 25 Jul 2020 23:47:35 +0000 Subject: [PATCH 21/30] client.rs formatting fix --- lambda/src/client.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda/src/client.rs b/lambda/src/client.rs index 88de0037..82b6e64c 100644 --- a/lambda/src/client.rs +++ b/lambda/src/client.rs @@ -63,10 +63,10 @@ mod endpoint_tests { use hyper::{server::conn::Http, service::service_fn, Body}; use serde_json::json; use std::convert::TryFrom; - use tokio::stream::StreamExt; use tokio::{ io::{AsyncRead, AsyncWrite}, select, + stream::StreamExt, sync::{self, oneshot}, }; From 7e58282e643610765b98d250c4b7d5818a5b33e5 Mon Sep 17 00:00:00 2001 From: rimutaka Date: Sun, 26 Jul 2020 10:15:06 +0000 Subject: [PATCH 22/30] Fixed "Process exited" error in lib.rs. --- lambda/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda/src/lib.rs b/lambda/src/lib.rs index 25997fbd..15b347e7 100644 --- a/lambda/src/lib.rs +++ b/lambda/src/lib.rs @@ -337,7 +337,7 @@ where .expect("Unable create runtime"); let client = &runtime.client; - let incoming = incoming(client).take(1); + let incoming = incoming(client); runtime.run(incoming, handler).await } From 7d9955550d836465c42d9a7a08d74d49b720dd03 Mon Sep 17 00:00:00 2001 From: rimutaka Date: Sun, 26 Jul 2020 11:01:49 +0000 Subject: [PATCH 23/30] Added some tracing!() to lib.rs. --- lambda/src/lib.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lambda/src/lib.rs b/lambda/src/lib.rs index 15b347e7..fb53aa8e 100644 --- a/lambda/src/lib.rs +++ b/lambda/src/lib.rs @@ -182,11 +182,13 @@ where let handler = Arc::new(handler); tokio::pin!(incoming); while let Some(event) = incoming.next().await { + trace!("New event arrived (run loop)"); let event = event?; let (parts, body) = event.into_parts(); let ctx: Context = Context::try_from(parts.headers)?; let body = hyper::body::to_bytes(body).await?; + trace!("{}", std::str::from_utf8(&body)?); // this may be very verbose let body = serde_json::from_slice(&body)?; let handler = Arc::clone(&handler); @@ -195,11 +197,14 @@ where let req = match task.await { Ok(response) => match response.await { - Ok(response) => EventCompletionRequest { - request_id, - body: response, + Ok(response) => { + trace!("Ok response from handler (run loop)"); + EventCompletionRequest { + request_id, + body: response, + } + .into_req() } - .into_req(), Err(err) => { error!("{}", err); // logs the error in CloudWatch EventErrorRequest { @@ -291,6 +296,7 @@ where { async_stream::stream! { loop { + trace!("Waiting for next event (incoming loop)"); let req = NextEventRequest.into_req().expect("Unable to construct request"); let res = client.call(req).await; yield res; From 166d63848419639c5c30ad3c263781613f8f9341 Mon Sep 17 00:00:00 2001 From: rimutaka Date: Mon, 17 Aug 2020 23:28:05 +0000 Subject: [PATCH 24/30] Enforced Send+Sync for http Handler impl. --- lambda-http/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lambda-http/src/lib.rs b/lambda-http/src/lib.rs index cf7e3eff..5d6fb32e 100644 --- a/lambda-http/src/lib.rs +++ b/lambda-http/src/lib.rs @@ -122,7 +122,7 @@ pub trait Handler: Sized { /// The type of Response this Handler will return type Response: IntoResponse; /// The type of Future this Handler will return - type Fut: Future> + 'static; + type Fut: Future> + Send + Sync + 'static; /// Function used to execute handler behavior fn call(&self, event: Request, context: Context) -> Self::Fut; } @@ -137,7 +137,7 @@ impl Handler for F where F: Fn(Request, Context) -> Fut, R: IntoResponse, - Fut: Future> + Send + 'static, + Fut: Future> + Send + Sync + 'static, { type Response = R; type Error = Error; @@ -150,7 +150,7 @@ where #[doc(hidden)] pub struct TransformResponse { is_alb: bool, - fut: Pin>>>, + fut: Pin> + Send + Sync>>, } impl Future for TransformResponse From 186b4dbec07bc8b3325d653491d596c5099a7e59 Mon Sep 17 00:00:00 2001 From: rimutaka Date: Tue, 18 Aug 2020 00:39:15 +0000 Subject: [PATCH 25/30] Added docs and missing _vars to reduce warnings --- lambda-http/src/request.rs | 56 +++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/lambda-http/src/request.rs b/lambda-http/src/request.rs index fd4e52d9..287a789a 100644 --- a/lambda-http/src/request.rs +++ b/lambda-http/src/request.rs @@ -102,42 +102,65 @@ impl LambdaRequest<'_> { } } +/// See [context-variable-reference](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html) for more detail. #[derive(Deserialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct ApiGatewayV2RequestContext { + /// The API owner's AWS account ID. pub account_id: String, + /// The identifier API Gateway assigns to your API. pub api_id: String, + /// The stringified value of the specified key-value pair of the context map returned from an API Gateway Lambda authorizer function. #[serde(default)] pub authorizer: HashMap, + /// The full domain name used to invoke the API. This should be the same as the incoming Host header. pub domain_name: String, + /// The first label of the $context.domainName. This is often used as a caller/customer identifier. pub domain_prefix: String, + /// The HTTP method used. pub http: Http, + /// The ID that API Gateway assigns to the API request. pub request_id: String, + /// Undocumented, could be resourcePath pub route_key: String, + /// The deployment stage of the API request (for example, Beta or Prod). pub stage: String, + /// Undocumented, could be requestTime pub time: String, + /// Undocumented, could be requestTimeEpoch pub time_epoch: usize, } +/// See [context-variable-reference](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html) for more detail. #[derive(Deserialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct ApiGatewayRequestContext { - //pub path: String, + /// The API owner's AWS account ID. pub account_id: String, + /// The identifier that API Gateway assigns to your resource. pub resource_id: String, + /// The deployment stage of the API request (for example, Beta or Prod). pub stage: String, + /// The ID that API Gateway assigns to the API request. pub request_id: String, + /// The path to your resource. For example, for the non-proxy request URI of `https://{rest-api-id.execute-api.{region}.amazonaws.com/{stage}/root/child`, The $context.resourcePath value is /root/child. pub resource_path: String, + /// The HTTP method used. Valid values include: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT. pub http_method: String, + /// The stringified value of the specified key-value pair of the context map returned from an API Gateway Lambda authorizer function. #[serde(default)] pub authorizer: HashMap, + /// The identifier API Gateway assigns to your API. pub api_id: String, + /// Cofnito identity information pub identity: Identity, } +/// Elastic load balancer context information #[derive(Deserialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct AlbRequestContext { + /// Elastic load balancer context information pub elb: Elb, } @@ -167,10 +190,17 @@ pub struct Elb { #[serde(rename_all = "camelCase")] pub struct Http { #[serde(deserialize_with = "deserialize_method")] + /// The HTTP method used. Valid values include: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT. pub method: http::Method, + /// The request path. For example, for a non-proxy request URL of + /// `https://{rest-api-id.execute-api.{region}.amazonaws.com/{stage}/root/child`, + /// the $context.path value is `/{stage}/root/child`. pub path: String, + /// The request protocol, for example, HTTP/1.1. pub protocol: String, + /// The source IP address of the TCP connection making the request to API Gateway. pub source_ip: String, + /// The User-Agent header of the API caller. pub user_agent: String, } @@ -178,17 +208,35 @@ pub struct Http { #[derive(Deserialize, Debug, Default, Clone)] #[serde(rename_all = "camelCase")] pub struct Identity { + /// The source IP address of the TCP connection making the request to API Gateway. pub source_ip: String, + /// The Amazon Cognito identity ID of the caller making the request. + /// Available only if the request was signed with Amazon Cognito credentials. pub cognito_identity_id: Option, + /// The Amazon Cognito identity pool ID of the caller making the request. + /// Available only if the request was signed with Amazon Cognito credentials. pub cognito_identity_pool_id: Option, + /// A comma-separated list of the Amazon Cognito authentication providers used by the caller making the request. + /// Available only if the request was signed with Amazon Cognito credentials. pub cognito_authentication_provider: Option, + /// The Amazon Cognito authentication type of the caller making the request. + /// Available only if the request was signed with Amazon Cognito credentials. pub cognito_authentication_type: Option, + /// The AWS account ID associated with the request. pub account_id: Option, + /// The principal identifier of the caller making the request. pub caller: Option, + /// For API methods that require an API key, this variable is the API key associated with the method request. + /// For methods that don't require an API key, this variable is null. pub api_key: Option, + /// Undocumented. Can be the API key ID associated with an API request that requires an API key. + /// The description of `api_key` and `access_key` may actually be reversed. pub access_key: Option, + /// The principal identifier of the user making the request. Used in Lambda authorizers. pub user: Option, + /// The User-Agent header of the API caller. pub user_agent: Option, + /// The Amazon Resource Name (ARN) of the effective user identified after authentication. pub user_arn: Option, } @@ -352,7 +400,7 @@ impl<'a> From> for http::Request { .expect("failed to build request"); // no builder method that sets headers in batch - mem::replace(req.headers_mut(), headers); + let _ = mem::replace(req.headers_mut(), headers); req } @@ -416,7 +464,7 @@ impl<'a> From> for http::Request { } // no builder method that sets headers in batch - mem::replace(req.headers_mut(), multi_value_headers); + let _ = mem::replace(req.headers_mut(), multi_value_headers); req } @@ -477,7 +525,7 @@ impl<'a> From> for http::Request { } // no builder method that sets headers in batch - mem::replace(req.headers_mut(), multi_value_headers); + let _ = mem::replace(req.headers_mut(), multi_value_headers); req } From 8e845856eb5ce91a8b2369e5d8ae4a3525962af3 Mon Sep 17 00:00:00 2001 From: rimutaka Date: Wed, 19 Aug 2020 09:22:27 +0000 Subject: [PATCH 26/30] Removed unnecessary + Sync on handler's future --- lambda/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lambda/src/lib.rs b/lambda/src/lib.rs index fb53aa8e..9025717f 100644 --- a/lambda/src/lib.rs +++ b/lambda/src/lib.rs @@ -130,7 +130,7 @@ pub struct HandlerFn { impl Handler for HandlerFn where F: Fn(A, Context) -> Fut, - Fut: Future> + Send + Sync, + Fut: Future> + Send, Error: Into> + fmt::Display, { type Error = Error; @@ -173,7 +173,7 @@ where ) -> Result<(), Error> where F: Handler + Send + Sync + 'static, - >::Fut: Future>::Error>> + Send + Sync + 'static, + >::Fut: Future>::Error>> + Send + 'static, >::Error: fmt::Display + Send + Sync + 'static, A: for<'de> Deserialize<'de> + Send + Sync + 'static, B: Serialize + Send + Sync + 'static, @@ -328,7 +328,7 @@ where pub async fn run(handler: F) -> Result<(), Error> where F: Handler + Send + Sync + 'static, - >::Fut: Future>::Error>> + Send + Sync + 'static, + >::Fut: Future>::Error>> + Send + 'static, >::Error: fmt::Display + Send + Sync + 'static, A: for<'de> Deserialize<'de> + Send + Sync + 'static, B: Serialize + Send + Sync + 'static, From 39e0cd1bca33d80b590fb09d427402e7dc806fe8 Mon Sep 17 00:00:00 2001 From: Blake Hildebrand Date: Sat, 30 Jan 2021 13:09:04 -0800 Subject: [PATCH 27/30] All tests passing --- Cargo.lock | 13 +++++++++++++ lambda/Cargo.toml | 2 ++ lambda/src/client.rs | 4 ++-- lambda/src/lib.rs | 2 +- lambda/src/simulated.rs | 2 +- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6d80ced8..d6287400 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -318,6 +318,8 @@ dependencies = [ "simple-error", "simple_logger", "tokio", + "tokio-stream", + "tower-service", "tracing", "tracing-error", "tracing-futures", @@ -743,6 +745,17 @@ dependencies = [ "syn", ] +[[package]] +name = "tokio-stream" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76066865172052eb8796c686f0b441a93df8b08d40a950b062ffb9a426f00edd" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + [[package]] name = "tower-service" version = "0.3.0" diff --git a/lambda/Cargo.toml b/lambda/Cargo.toml index 4d5bb241..8237d380 100644 --- a/lambda/Cargo.toml +++ b/lambda/Cargo.toml @@ -26,6 +26,8 @@ futures = "0.3" tracing-error = "0.1.2" tracing = { version = "0.1", features = ["log"] } tracing-futures = "0.2" +tower-service = "0.3" +tokio-stream = "0.1.2" [dev-dependencies] tracing-subscriber = "0.2" diff --git a/lambda/src/client.rs b/lambda/src/client.rs index 82b6e64c..b24b2e78 100644 --- a/lambda/src/client.rs +++ b/lambda/src/client.rs @@ -66,9 +66,9 @@ mod endpoint_tests { use tokio::{ io::{AsyncRead, AsyncWrite}, select, - stream::StreamExt, sync::{self, oneshot}, }; + use tokio_stream::StreamExt; #[cfg(test)] async fn next_event(req: &Request) -> Result, Error> { @@ -134,7 +134,7 @@ mod endpoint_tests { } #[cfg(test)] - async fn handle(io: I, rx: oneshot::Receiver<()>) -> Result<(), hyper::error::Error> + async fn handle(io: I, rx: oneshot::Receiver<()>) -> Result<(), hyper::Error> where I: AsyncRead + AsyncWrite + Unpin + 'static, { diff --git a/lambda/src/lib.rs b/lambda/src/lib.rs index 9025717f..59dac5b7 100644 --- a/lambda/src/lib.rs +++ b/lambda/src/lib.rs @@ -52,8 +52,8 @@ use std::{ }; use tokio::{ io::{AsyncRead, AsyncWrite}, - stream::{Stream, StreamExt}, }; +use tokio_stream::{Stream, StreamExt}; use tower_service::Service; use tracing::{error, trace}; diff --git a/lambda/src/simulated.rs b/lambda/src/simulated.rs index 887906a7..7d1931c3 100644 --- a/lambda/src/simulated.rs +++ b/lambda/src/simulated.rs @@ -40,7 +40,7 @@ pub struct Connector { pub inner: SimStream, } -impl hyper::service::Service for SimulatedConnector { +impl hyper::service::Service for Connector { type Response = SimStream; type Error = std::io::Error; type Future = Pin> + Send>>; From 222f91562ae2f27f876866e52db64f32a36d669b Mon Sep 17 00:00:00 2001 From: Blake Hildebrand Date: Sat, 30 Jan 2021 15:30:05 -0800 Subject: [PATCH 28/30] Remove deprecated simple_logger calls --- lambda/examples/basic.rs | 8 ++++++-- lambda/examples/error-handling.rs | 8 +++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lambda/examples/basic.rs b/lambda/examples/basic.rs index 2d2ad02d..2b71ec24 100644 --- a/lambda/examples/basic.rs +++ b/lambda/examples/basic.rs @@ -2,8 +2,9 @@ // { "command": "do something" } use lambda::{handler_fn, Context}; +use log::LevelFilter; use serde::{Deserialize, Serialize}; -use simple_logger; +use simple_logger::SimpleLogger; /// A shorthand for `Box` /// type required by aws-lambda-rust-runtime. @@ -31,7 +32,10 @@ struct Response { async fn main() -> Result<(), Error> { // required to enable CloudWatch error logging by the runtime // can be replaced with any other method of initializing `log` - simple_logger::init_with_level(log::Level::Info)?; + SimpleLogger::new() + .with_level(LevelFilter::Info) + .init() + .unwrap(); let func = handler_fn(my_handler); lambda::run(func).await?; diff --git a/lambda/examples/error-handling.rs b/lambda/examples/error-handling.rs index a94579a0..487e1198 100644 --- a/lambda/examples/error-handling.rs +++ b/lambda/examples/error-handling.rs @@ -1,9 +1,12 @@ /// See https://github.com/awslabs/aws-lambda-rust-runtime for more info on Rust runtime for AWS Lambda use lambda::handler_fn; +use log::LevelFilter; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; +use simple_logger::SimpleLogger; use std::fs::File; + /// A shorthand for `Box` type required by aws-lambda-rust-runtime. pub type Error = Box; @@ -57,7 +60,10 @@ async fn main() -> Result<(), Error> { // You can comment out the `simple_logger` init line and uncomment the following block to // use `tracing` in the handler function. // - simple_logger::init_with_level(log::Level::Info)?; + SimpleLogger::new() + .with_level(LevelFilter::Info) + .init() + .unwrap(); /* tracing_subscriber::fmt() .with_max_level(tracing::Level::INFO) From aa763376bd20a4abca4948588697a7953b7e3bc8 Mon Sep 17 00:00:00 2001 From: Blake Hildebrand Date: Tue, 2 Feb 2021 17:31:13 -0800 Subject: [PATCH 29/30] Remove Cargo.lock --- Cargo.lock | 928 ----------------------------------------------------- 1 file changed, 928 deletions(-) delete mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index a4f08106..00000000 --- a/Cargo.lock +++ /dev/null @@ -1,928 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - -[[package]] -name = "async-stream" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3670df70cbc01729f901f94c887814b3c68db038aad1329a418bae178bc5295c" -dependencies = [ - "async-stream-impl", - "futures-core", -] - -[[package]] -name = "async-stream-impl" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3548b8efc9f8e8a5a0a2808c5bd8451a9031b9e5b879a79590304ae928b0a70" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "base64" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" - -[[package]] -name = "byteorder" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" - -[[package]] -name = "bytes" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "chrono" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" -dependencies = [ - "libc", - "num-integer", - "num-traits", - "time", - "winapi", -] - -[[package]] -name = "colored" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59" -dependencies = [ - "atty", - "lazy_static", - "winapi", -] - -[[package]] -name = "dtoa" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d7ed2934d741c6b37e33e3832298e8850b53fd2d2bea03873375596c7cea4e" - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "form_urlencoded" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00" -dependencies = [ - "matches", - "percent-encoding", -] - -[[package]] -name = "futures" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9052a1a50244d8d5aa9bf55cbc2fb6f357c86cc52e46c62ed390a7180cf150" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2d31b7ec7efab6eefc7c57233bb10b847986139d88cc2f5a02a1ae6871a1846" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e5145dde8da7d1b3892dad07a9c98fc04bc39892b1ecc9692cf53e2b780a65" - -[[package]] -name = "futures-executor" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e59fdc009a4b3096bf94f740a0f2424c082521f20a9b08c5c07c48d90fd9b9" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28be053525281ad8259d47e4de5de657b25e7bac113458555bb4b70bc6870500" - -[[package]] -name = "futures-macro" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c287d25add322d9f9abdcdc5927ca398917996600182178774032e9f8258fedd" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-sink" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caf5c69029bda2e743fddd0582d1083951d65cc9539aebf8812f36c3491342d6" - -[[package]] -name = "futures-task" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13de07eb8ea81ae445aca7b69f5f7bf15d7bf4912d8ca37d6645c77ae8a58d86" -dependencies = [ - "once_cell", -] - -[[package]] -name = "futures-util" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632a8cd0f2a4b3fdea1657f08bde063848c3bd00f9bbf6e256b8be78802e624b" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "proc-macro-hack", - "proc-macro-nested", - "slab", -] - -[[package]] -name = "hermit-abi" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" -dependencies = [ - "libc", -] - -[[package]] -name = "http" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994" -dependencies = [ - "bytes", - "http", -] - -[[package]] -name = "httparse" -version = "1.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "615caabe2c3160b313d52ccc905335f4ed5f10881dd63dc5699d47e90be85691" - -[[package]] -name = "httpdate" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" - -[[package]] -name = "hyper" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12219dc884514cb4a6a03737f4413c0e01c23a1b059b0156004b23f1e19dccbe" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project 1.0.4", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "idna" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "itoa" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" - -[[package]] -name = "lambda" -version = "0.1.0" -dependencies = [ - "async-stream", - "bytes", - "futures", - "http", - "hyper", - "log", - "once_cell", - "serde", - "serde_json", - "simple-error", - "simple_logger", - "tokio", - "tokio-stream", - "tower-service", - "tracing", - "tracing-error", - "tracing-futures", - "tracing-subscriber", -] - -[[package]] -name = "lambda_http" -version = "0.2.0-beta.1" -dependencies = [ - "base64", - "http", - "lambda", - "log", - "maplit", - "serde", - "serde_json", - "serde_urlencoded", - "tokio", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.85" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ccac4b00700875e6a07c6cde370d44d32fa01c5a65cdd2fca6858c479d28bb3" - -[[package]] -name = "log" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "maplit" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" - -[[package]] -name = "matchers" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" -dependencies = [ - "regex-automata", -] - -[[package]] -name = "matches" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" - -[[package]] -name = "memchr" -version = "2.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" - -[[package]] -name = "mio" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e50ae3f04d169fcc9bde0b547d1c205219b7157e07ded9c5aff03e0637cb3ed7" -dependencies = [ - "libc", - "log", - "miow", - "ntapi", - "winapi", -] - -[[package]] -name = "miow" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" -dependencies = [ - "socket2", - "winapi", -] - -[[package]] -name = "ntapi" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" -dependencies = [ - "winapi", -] - -[[package]] -name = "num-integer" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" -dependencies = [ - "autocfg", -] - -[[package]] -name = "num_cpus" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "once_cell" -version = "1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" - -[[package]] -name = "percent-encoding" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" - -[[package]] -name = "pin-project" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15" -dependencies = [ - "pin-project-internal 0.4.27", -] - -[[package]] -name = "pin-project" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b70b68509f17aa2857863b6fa00bf21fc93674c7a8893de2f469f6aa7ca2f2" -dependencies = [ - "pin-project-internal 1.0.4", -] - -[[package]] -name = "pin-project-internal" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-internal" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caa25a6393f22ce819b0f50e0be89287292fda8d425be38ee0ca14c4931d9e71" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - -[[package]] -name = "proc-macro-nested" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" - -[[package]] -name = "proc-macro2" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "quote" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "regex" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" -dependencies = [ - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" -dependencies = [ - "byteorder", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" - -[[package]] -name = "ryu" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" - -[[package]] -name = "serde" -version = "1.0.123" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.123" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_urlencoded" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" -dependencies = [ - "dtoa", - "itoa", - "serde", - "url", -] - -[[package]] -name = "sharded-slab" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79c719719ee05df97490f80a45acfc99e5a30ce98a1e4fb67aee422745ae14e3" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "simple-error" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc47a29ce97772ca5c927f75bac34866b16d64e07f330c3248e2d7226623901b" - -[[package]] -name = "simple_logger" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd57f17c093ead1d4a1499dc9acaafdd71240908d64775465543b8d9a9f1d198" -dependencies = [ - "atty", - "chrono", - "colored", - "log", - "winapi", -] - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" - -[[package]] -name = "smallvec" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" - -[[package]] -name = "socket2" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" -dependencies = [ - "cfg-if", - "libc", - "winapi", -] - -[[package]] -name = "syn" -version = "1.0.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "thread_local" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8208a331e1cb318dd5bd76951d2b8fc48ca38a69f5f4e4af1b6a9f8c6236915" -dependencies = [ - "once_cell", -] - -[[package]] -name = "time" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" -dependencies = [ - "libc", - "wasi", - "winapi", -] - -[[package]] -name = "tinyvec" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" - -[[package]] -name = "tokio" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6714d663090b6b0acb0fa85841c6d66233d150cdb2602c8f9b8abb03370beb3f" -dependencies = [ - "autocfg", - "bytes", - "libc", - "memchr", - "mio", - "num_cpus", - "pin-project-lite", - "tokio-macros", -] - -[[package]] -name = "tokio-macros" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42517d2975ca3114b22a16192634e8241dc5cc1f130be194645970cc1c371494" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tokio-stream" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76066865172052eb8796c686f0b441a93df8b08d40a950b062ffb9a426f00edd" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tower-service" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" - -[[package]] -name = "tracing" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" -dependencies = [ - "cfg-if", - "log", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "tracing-error" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4d7c0b83d4a500748fa5879461652b361edf5c9d51ede2a2ac03875ca185e24" -dependencies = [ - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "tracing-futures" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" -dependencies = [ - "pin-project 0.4.27", - "tracing", -] - -[[package]] -name = "tracing-log" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e0f8c7178e13481ff6765bd169b33e8d554c5d2bbede5e32c356194be02b9b9" -dependencies = [ - "lazy_static", - "log", - "tracing-core", -] - -[[package]] -name = "tracing-serde" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b" -dependencies = [ - "serde", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1fa8f0c8f4c594e4fc9debc1990deab13238077271ba84dd853d54902ee3401" -dependencies = [ - "ansi_term", - "chrono", - "lazy_static", - "matchers", - "regex", - "serde", - "serde_json", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", - "tracing-serde", -] - -[[package]] -name = "try-lock" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" - -[[package]] -name = "unicode-bidi" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -dependencies = [ - "matches", -] - -[[package]] -name = "unicode-normalization" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-xid" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" - -[[package]] -name = "url" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e" -dependencies = [ - "form_urlencoded", - "idna", - "matches", - "percent-encoding", -] - -[[package]] -name = "want" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" -dependencies = [ - "log", - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" From 55caad8d97ec8bc801414cead080220c898b84a8 Mon Sep 17 00:00:00 2001 From: Blake Hildebrand Date: Tue, 2 Feb 2021 17:43:05 -0800 Subject: [PATCH 30/30] cargo fmt changes --- lambda/examples/basic.rs | 5 +---- lambda/examples/error-handling.rs | 6 +----- lambda/src/lib.rs | 4 +--- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/lambda/examples/basic.rs b/lambda/examples/basic.rs index 2b71ec24..7b492a44 100644 --- a/lambda/examples/basic.rs +++ b/lambda/examples/basic.rs @@ -32,10 +32,7 @@ struct Response { async fn main() -> Result<(), Error> { // required to enable CloudWatch error logging by the runtime // can be replaced with any other method of initializing `log` - SimpleLogger::new() - .with_level(LevelFilter::Info) - .init() - .unwrap(); + SimpleLogger::new().with_level(LevelFilter::Info).init().unwrap(); let func = handler_fn(my_handler); lambda::run(func).await?; diff --git a/lambda/examples/error-handling.rs b/lambda/examples/error-handling.rs index 487e1198..1b061254 100644 --- a/lambda/examples/error-handling.rs +++ b/lambda/examples/error-handling.rs @@ -6,7 +6,6 @@ use serde_json::{json, Value}; use simple_logger::SimpleLogger; use std::fs::File; - /// A shorthand for `Box` type required by aws-lambda-rust-runtime. pub type Error = Box; @@ -60,10 +59,7 @@ async fn main() -> Result<(), Error> { // You can comment out the `simple_logger` init line and uncomment the following block to // use `tracing` in the handler function. // - SimpleLogger::new() - .with_level(LevelFilter::Info) - .init() - .unwrap(); + SimpleLogger::new().with_level(LevelFilter::Info).init().unwrap(); /* tracing_subscriber::fmt() .with_max_level(tracing::Level::INFO) diff --git a/lambda/src/lib.rs b/lambda/src/lib.rs index 9a77a403..44077f0e 100644 --- a/lambda/src/lib.rs +++ b/lambda/src/lib.rs @@ -15,9 +15,7 @@ use std::{ future::Future, sync::Arc, }; -use tokio::{ - io::{AsyncRead, AsyncWrite}, -}; +use tokio::io::{AsyncRead, AsyncWrite}; use tokio_stream::{Stream, StreamExt}; use tower_service::Service; use tracing::{error, trace};