Skip to content

rewrite extension client and upgrade tokio#120

Merged
bnusunny merged 2 commits intomainfrom
lambda_extension_rewrite
Jan 8, 2023
Merged

rewrite extension client and upgrade tokio#120
bnusunny merged 2 commits intomainfrom
lambda_extension_rewrite

Conversation

@bnusunny
Copy link
Copy Markdown
Contributor

@bnusunny bnusunny commented Jan 7, 2023

replace lambda-extension crate with inline extension client to reduce binary size by another 1MB.

-rwxr-xr-x  1 sunhua  staff   3.7M Jan  7 13:22 target/release/lambda-adapter

Upgrade tokio to 1.24 for improved performance

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

replace lambda-extension crate with inline extension client to reduce file size.

Upgrade tokio to 1.24 for improved performance
Copy link
Copy Markdown
Contributor

@calavera calavera left a comment

Choose a reason for hiding this comment

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

oh, this is interesting. I wonder what makes the extension crate compile size as big 🤔 I'll look into it too. Do you only care about one event? I don't understand how it works, I'm guessing Lambda will just queue the events for the extension and eventually discard them?

Comment thread src/lib.rs
let aws_lambda_runtime_api: String =
env::var("AWS_LAMBDA_RUNTIME_API").unwrap_or_else(|_| "127.0.0.1:9001".to_string());
let client = hyper::Client::new();
let register_req = hyper::Request::builder()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you're missing the User-Agent based on the environment variable that the lambda client injects for you.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is fine. We want to track invokes, not extensions registration calls.

@bnusunny bnusunny merged commit c36f127 into main Jan 8, 2023
@bnusunny bnusunny deleted the lambda_extension_rewrite branch January 8, 2023 01:03
@bnusunny
Copy link
Copy Markdown
Contributor Author

bnusunny commented Jan 8, 2023

An extension tells Lambda Service what events it's interested in by specifying the event names when it registers. Lambda will send only those events to the extension.

The adapter specified no event names at registration. So Lambda will not return any events to it. The NEXT call will block forever.

@bnusunny
Copy link
Copy Markdown
Contributor Author

bnusunny commented Jan 8, 2023

lambda-extension crate is a bit bloated. Probably should split into 3 crates: minimum base extension crate for extension api, logs api crate, and telemetry api crate.

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.

2 participants