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

rewrite extension client and upgrade tokio #120

Merged
merged 2 commits into from
Jan 8, 2023
Merged

Conversation

bnusunny
Copy link
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
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?

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
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
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
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
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