-
Notifications
You must be signed in to change notification settings - Fork 380
feat: support Lambda Managed Instances (draft) #1067
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
Open
alessandrobologna
wants to merge
13
commits into
aws:main
Choose a base branch
from
alessandrobologna:feat/concurrent-lambda-runtime
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
45d7bfa
feat: support Lambda Managed Instances
alessandrobologna f23199b
feat(runtime,http): add concurrent entrypoints without changing run
alessandrobologna a80252d
chore(runtime): tighten diff vs main and clean up API client builder
alessandrobologna 0cb078e
chore: ignore local docs and RIE Dockerfile
alessandrobologna 6811a09
chore: restore .gitignore to match upstream
alessandrobologna 2d7e780
fix(lambda-http): export run_with_streaming_response_concurrent
alessandrobologna 1bab0b5
refactor(runtime): N worker /next loops for managed concurrency
alessandrobologna 6835047
fix(runtime): refine concurrent worker isolation
alessandrobologna d4ed7d7
fix: address CI lint and clarify worker-exit log
alessandrobologna 40c444c
fix(runtime): keep concurrency settings internal
alessandrobologna 96b605a
fix(lambda-http): source X-Ray trace id from context
alessandrobologna ce6d503
runtime: improve concurrent worker supervision
alessandrobologna e2ec3b0
runtime: refine worker supervision logging
alessandrobologna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| [package] | ||
| name = "basic-lambda-concurrent" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
|
|
||
| [dependencies] | ||
| lambda_runtime = { path = "../../lambda-runtime" } | ||
| serde = "1.0.219" | ||
| tokio = { version = "1", features = ["macros"] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // This example requires the following input to succeed: | ||
| // { "command": "do something" } | ||
|
|
||
| use lambda_runtime::{service_fn, tracing, Error, LambdaEvent}; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| /// This is also a made-up example. Requests come into the runtime as unicode | ||
| /// strings in json format, which can map to any structure that implements `serde::Deserialize` | ||
| /// The runtime pays no attention to the contents of the request payload. | ||
| #[derive(Deserialize)] | ||
| struct Request { | ||
| command: String, | ||
| } | ||
|
|
||
| /// This is a made-up example of what a response structure may look like. | ||
| /// There is no restriction on what it can be. The runtime requires responses | ||
| /// to be serialized into json. The runtime pays no attention | ||
| /// to the contents of the response payload. | ||
| #[derive(Serialize)] | ||
| struct Response { | ||
| req_id: String, | ||
| msg: String, | ||
| } | ||
|
|
||
| #[tokio::main] | ||
| async fn main() -> Result<(), Error> { | ||
| // required to enable CloudWatch error logging by the runtime | ||
| tracing::init_default_subscriber(); | ||
|
|
||
| let func = service_fn(my_handler); | ||
| if let Err(err) = lambda_runtime::run_concurrent(func).await { | ||
| tracing::error!(error = %err, "run error"); | ||
| return Err(err); | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| pub(crate) async fn my_handler(event: LambdaEvent<Request>) -> Result<Response, Error> { | ||
| // extract some useful info from the request | ||
| let command = event.payload.command; | ||
|
|
||
| // prepare the response | ||
| let resp = Response { | ||
| req_id: event.context.request_id, | ||
| msg: format!("Command {command} executed."), | ||
| }; | ||
|
|
||
| // return `Response` (it will be serialized to JSON automatically by the runtime) | ||
| Ok(resp) | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use crate::{my_handler, Request}; | ||
| use lambda_runtime::{Context, LambdaEvent}; | ||
|
|
||
| #[tokio::test] | ||
| async fn response_is_good_for_simple_input() { | ||
| let id = "ID"; | ||
|
|
||
| let mut context = Context::default(); | ||
| context.request_id = id.to_string(); | ||
|
|
||
| let payload = Request { | ||
| command: "X".to_string(), | ||
| }; | ||
| let event = LambdaEvent { payload, context }; | ||
|
|
||
| let result = my_handler(event).await.unwrap(); | ||
|
|
||
| assert_eq!(result.msg, "Command X executed."); | ||
| assert_eq!(result.req_id, id.to_string()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.