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

Add a dedicated lambda bin #218

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

rustworthy
Copy link
Contributor

@rustworthy rustworthy commented Jan 19, 2025

This is the first iteration on #202

I have not found a way to provide flags/args to the lambda runtime, they just taking a bootstrap binary from us and that's it.

So what I am suggesting instead, is to locate the core logic in the lib and have numerous binaries - two for now. The default bin will be binding to a socket, while the --bin lambda will produce a lambda-layered app ready for AWS Lambda runtime. This has a benefit of only including the code we need to the default binary and not adding lambda runtime specific stuff.

We will still need logic for parsing command line args for the default binary (to accomplish the testing aspect of #202), but I think we could address it in a dedicated PR.

P.S.: I am suggesting to put auxiliary functions to the utils module

@@ -236,7 +237,7 @@ async fn list_inner(
let votes = q["votes"].as_u64().expect("votes is a number") as f64;
// max so that even if vote count somehow got to 0, count it as 1
let votes = votes.max(1.);
let exp = (-1. * dt as f64).exp_m1() + 1.;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

clippy yelled at me

Comment on lines +204 to +209
// NB! If you are creating entries manually via the DynamoDB Web UI (or CLI)
// when developing and testing, make sure you are putting valid ulids as ids,
// since the db server will only check that `id` respects the `S` type, and so
// will not error back to you when you are saving a question (say, via Web UI)
// with `id="string-that-is-not-valid-ulid"`.
ulid::Ulid::from_string(id).expect("all ids to be valid ulids in the table")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

addresses thread

@rustworthy rustworthy changed the title [WIP] Make --release not special [WIP] Add a dedicated lambda bin Jan 19, 2025
cargo lambda build --release --arm64
cargo lambda deploy --env-var RUST_LOG=info,tower_http=debug,wewerewondering_api=trace --profile qa
cargo lambda build --release --arm64 --bin lambda
cargo lambda deploy --env-var RUST_LOG=info,tower_http=debug,lambda=trace --profile qa --binary-name lambda
Copy link
Contributor Author

Choose a reason for hiding this comment

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

lambda=trace might be a bit ambiguous, but lambda here is the app's name

@rustworthy rustworthy changed the title [WIP] Add a dedicated lambda bin Add a dedicated lambda bin Jan 19, 2025
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.

1 participant