Skip to content
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

Feature flags for lambda_http #497

Merged
merged 5 commits into from
Jul 6, 2022
Merged

Feature flags for lambda_http #497

merged 5 commits into from
Jul 6, 2022

Conversation

calavera
Copy link
Contributor

@calavera calavera commented Jul 2, 2022

Add feature flags to lambda_http so consumer can decide which service their events come from. This makes compilation much faster when you don't put the same Lambda function behind multiple services.

I've tested these changes in a simple function behind APIGW, and compilation time for a pre-compiled function drops from 18 seconds to 5 seconds.

Signed-off-by: David Calavera david.calavera@gmail.com

Issue #, if available:

Fixes #481

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.

Add feature flags to lambda_http so consumer can decide which service their events come from. This makes compilation much faster when you don't put the same Lambda function behind multiple services.

Signed-off-by: David Calavera <david.calavera@gmail.com>
@@ -330,12 +330,6 @@ You can read more about how [cargo lambda start](https://github.com/calavera/car

Lambdas can be run and debugged locally using a special [Lambda debug proxy](https://github.com/rimutaka/lambda-debug-proxy) (a non-AWS repo maintained by @rimutaka), which is a Lambda function that forwards incoming requests to one AWS SQS queue and reads responses from another queue. A local proxy running on your development computer reads the queue, calls your Lambda locally and sends back the response. This approach allows debugging of Lambda functions locally while being part of your AWS workflow. The Lambda handler code does not need to be modified between the local and AWS versions.

## `lambda_runtime`
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've removed this because it's part of an old readme, and we didn't notice until now. It doesn't make sense anymore in this context.

Copy link
Contributor

@david-perez david-perez left a comment

Choose a reason for hiding this comment

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

Implementation looks good. Minor comments about wording in the readme.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Use the names present in the API GW documentation to differentiate the APIs.

Signed-off-by: David Calavera <david.calavera@gmail.com>
@calavera
Copy link
Contributor Author

calavera commented Jul 4, 2022

@david-perez thanks for the feedback. I decided to change the feature names to match how the different APIs are described in the API GW documentation:

https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html

Signed-off-by: David Calavera <david.calavera@gmail.com>
README.md Outdated
@@ -378,6 +372,30 @@ fn main() -> Result<(), Box<Error>> {
}
```

## Feature flags in lambda_http

`lambda_http` is a wrapper for HTTP events coming from two different services, Amazon Load Balancer (ALB), and Amazon Api Gateway (APIGW). Amazon Api Gateway can also send events from three different endpoints, Proxy V1, Proxy V2, and WebSockets. `lambda_http` transforms events from all these sources into native `http::Request` objects, so you can incorporate Rust HTTP semantics into your Lambda functions.
Copy link
Contributor

@bnusunny bnusunny Jul 5, 2022

Choose a reason for hiding this comment

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

lambda_http actually supports three sources: ALB, APIGW, and the new Lambda Function URLs. Lambda Function URLs use the same format as APIGW HTTP API payload format version 2.0. So it works out of box.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, I've updated the readme.

Signed-off-by: David Calavera <david.calavera@gmail.com>
README.md Outdated Show resolved Hide resolved
Signed-off-by: David Calavera <david.calavera@gmail.com>
@calavera calavera requested a review from bnusunny July 5, 2022 16:00
@calavera calavera merged commit ff948fa into main Jul 6, 2022
@calavera calavera deleted the http_features branch July 6, 2022 00:49
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.

Improving Compile Times And/Or Add Pluggable Deserializable Types
3 participants