From abe774a359b33f82319b404209a3d5ae30710d55 Mon Sep 17 00:00:00 2001 From: Bryan Moffatt Date: Fri, 6 Dec 2019 15:55:17 +0000 Subject: [PATCH] send the runtime user agent when polling for events --- Cargo.lock | 4 ++-- lambda-runtime-client/Cargo.toml | 4 ++-- lambda-runtime-client/src/client.rs | 9 ++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ae5bbaf7..d5e54134 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -340,7 +340,7 @@ dependencies = [ [[package]] name = "lambda_runtime_client" -version = "0.2.2" +version = "0.2.3" dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -362,7 +362,7 @@ dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.24 (registry+https://github.com/rust-lang/crates.io-index)", - "lambda_runtime_client 0.2.2", + "lambda_runtime_client 0.2.3", "lambda_runtime_errors 0.1.1", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/lambda-runtime-client/Cargo.toml b/lambda-runtime-client/Cargo.toml index bf5dcef9..e4c962de 100644 --- a/lambda-runtime-client/Cargo.toml +++ b/lambda-runtime-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lambda_runtime_client" -version = "0.2.2" +version = "0.2.3" authors = ["Stefano Buliani", "David Barsky"] edition = "2018" description = "Client SDK for AWS Lambda's runtime APIs" @@ -27,4 +27,4 @@ lambda_runtime_errors = { path = "../lambda-runtime-errors", version = "^0.1" } failure = "^0.1" [dev-dependencies] -chrono = "^0.4" \ No newline at end of file +chrono = "^0.4" diff --git a/lambda-runtime-client/src/client.rs b/lambda-runtime-client/src/client.rs index 11e70dd2..02ffca08 100644 --- a/lambda-runtime-client/src/client.rs +++ b/lambda-runtime-client/src/client.rs @@ -171,12 +171,19 @@ impl<'ev> RuntimeClient { pub fn next_event(&self) -> Result<(Vec, EventContext), ApiError> { trace!("Polling for next event"); + let req = Request::builder() + .method(Method::GET) + .uri(self.next_endpoint.clone()) + .header(header::USER_AGENT, self.runtime_agent.clone()) + .body(Body::from("")) + .unwrap(); + // We wait instead of processing the future asynchronously because AWS Lambda // itself enforces only one event per container at a time. No point in taking on // the additional complexity. let resp = self .http_client - .get(self.next_endpoint.clone()) + .request(req) .wait() .context(ApiErrorKind::Unrecoverable("Could not fetch next event".to_string()))?;