Skip to content

Conversation

davidbarsky
Copy link
Contributor

Issue #, if available: N/A

Description of changes:

This branch has a few changes:

  1. Since AWS X-Ray is now availible in GovCloud, we can make the trace id in the context non-optional.
  2. The (internal) runtime client is now takes a &self instead of a &mut self, reducing how many .clone()s we need need to write. This also means that the client no longer implements tower::Service, but given that functionality wasn't used anyways, I don't consider this to much of a loss.
  3. We're now modeling the incoming events as a stream using the (awesome!) genawaiter crate. This can be replaced with a manual stream implementation + pin_project_lite in the future. Side note: the Lambda Runtime server-side APIs (for those unfamiliar, the Firecracker boxes) suspend the function once they receive the next_event call, not the response handler. This allows for races to be cleanly-side stepped.

Still upcoming:

  1. tracing support for logs, metrics, and distributed tracing (e.g., AWS X-Ray Integration).
  2. Docs!
  3. Refactoring the test support to not rely sending requests over localhost as per https://github.com/davidbarsky/stuff. Props to Dylan Marriner on the Lambda team and @gardnervickers for the tip and approach.

By submitting this pull request

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

@davidbarsky davidbarsky requested a review from sapessi March 22, 2020 17:50
//! }
//! ```
pub use crate::types::LambdaCtx;
use anyhow::Error;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a fan of anyhow but do you think exposing this is the outward facing api is going to last?

I asking because I feel like this is a trap the use error crates in libraries in the rust ecosystem in the past. On year is error_chain, the next year it's failure, the next year it's anyhow. I think these are all really good for use in applications but for library crates it's problematic when the community shifts its opinions forcing applications to deal with breaking library changes when that happens.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it shouldn't be exposed, I'm just very lazy! At the very most, we should depend on thiserror, which was designed to be safely used by libraries by just expanding to std::error::Error with no trace of thiserror. A future removal of thiserror will be equivalent to hand-written std::error::Error implementation.


Now that I think of it, I think that I can write all of the errors using thiserror, but only publish the slightly cleaned up cargo expand output.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 we've been down this error path before. We should try and expose only std errors without forcing an opinion/dependency on function developers

Copy link
Contributor Author

@davidbarsky davidbarsky Apr 27, 2020

Choose a reason for hiding this comment

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

Yeah, I'll drop it in the next PR and use std::error::Error without any derives. I primarily want to merge this as is so that some other folks can build on these changes more easily.

}
fn incoming(client: &Client) -> impl Stream<Item = Result<http::Response<hyper::Body>, Error>> + '_ {
gen!({
let req = NextEventRequest.into_req().expect("Unable to construct request");
Copy link
Contributor

Choose a reason for hiding this comment

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

well that was neat!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree!

Copy link
Contributor

@sapessi sapessi left a comment

Choose a reason for hiding this comment

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

Just one comment on the anyhow dependency.

//! }
//! ```
pub use crate::types::LambdaCtx;
use anyhow::Error;
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 we've been down this error path before. We should try and expose only std errors without forcing an opinion/dependency on function developers

@davidbarsky davidbarsky merged commit 3fa8df3 into master Apr 27, 2020
@rimutaka rimutaka mentioned this pull request Jul 22, 2020
2 tasks
@nmoutschen nmoutschen deleted the david/cleanup-master-branch branch February 1, 2022 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants