-
Notifications
You must be signed in to change notification settings - Fork 361
Make lambda::Context a first class part of the Handler api #233
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
Conversation
async fn actual(#arg_name: #arg_type) #ret { | ||
#body | ||
} | ||
async fn actual(#event_name: #event_type, #context_name: #context_type) #ret #body |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: I ditched the branches because I noticed a warning emitted about needless braces. we debugging the result I could see that body actually included braces so the result looked like async fn actual(foo: XXX, bar: XXX) -> Ret { { ... } }
hence I omitted the extra braces to avoid potential user confusion with rust warnings
|
||
if is_http(&args) { | ||
quote_spanned! { input.span() => | ||
use lambda_http::lambda::LambdaCtx; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not actually sure why these were here before but they cased duplicate import errors as handlers no import this type themselves in their function signatures
Something that made me itch a bit is the name |
I've always really enjoyed type names that are very concise, and lean on the module to preserve the context of the type ( |
@cakekindel I'm with you :) |
I think we should push customers (and in examples) to write |
Happy to add that here or after a merge. Which ever comes first |
Eh, it’s more of a value statement. Happy to merge this thing in first. |
I ended out doing a quick find and replace |
I think we should get rid of the |
me too #237 |
FWIW, @softprops it was a breaking change going from #231 ( Here's my error: error[E0593]: function is expected to take 2 arguments, but it takes 1 argument
--> src/cmd/lambda/main.rs:91:25
|
53 | async fn entrypoint(req: lambda_http::Request) -> Result<impl IntoResponse, AsyncError> {
| --------------------------------------------------------------------------------------- takes 1 argument
...
91 | lambda::run(handler(entrypoint)).await?;
| ^^^^^^^^^^ expected function that takes 2 arguments
|
::: /Users/sean/.cargo/git/checkouts/aws-lambda-rust-runtime-7c865cce90132439/ae3ce1d/lambda-http/src/lib.rs:131:19
|
131 | pub fn handler<H: Handler>(handler: H) -> Adapter<H> {
| ------- required by this bound in `lambda_http::handler`
|
= note: required because of the requirements on the impl of `lambda_http::Handler` for `fn(http::request::Request<lambda_http::body::Body>) -> impl std::future::Future {entrypoint}` |
@seanpianka this is expected. Note depending on master holds different guarantees than depending on a release version. There are no guarantees on on API stability on the master branch as it represents active development. We are hoping to pin down what the next release version looks like which, for those depending on the latest release version, should expect a number of breaking changes |
I've since pinned the crate at lambda_http = { git = "https://github.com/awslabs/aws-lambda-rust-runtime/", rev = "ed3fd16" } As it seems the guarantees from depending on master are not suitable for my needs. |
Issue #, if available:
Description of changes:
This makes LambdaCtx a second argument passed to handler types
This makes for a bit more consistency with handler apis in other runtimes like node, python, and ruby
See conversation here
update:
This change also renames
lambda::LambdaCtx
tolambda::Context
By submitting this pull request