Skip to content

send the runtime user agent when polling for events #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions lambda-runtime-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -27,4 +27,4 @@ lambda_runtime_errors = { path = "../lambda-runtime-errors", version = "^0.1" }
failure = "^0.1"

[dev-dependencies]
chrono = "^0.4"
chrono = "^0.4"
9 changes: 8 additions & 1 deletion lambda-runtime-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,19 @@ impl<'ev> RuntimeClient {
pub fn next_event(&self) -> Result<(Vec<u8>, 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()))?;

Expand Down