-
Notifications
You must be signed in to change notification settings - Fork 173
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
RUST-1253 Add AWS Lambda Examples #714
RUST-1253 Add AWS Lambda Examples #714
Conversation
|
||
#[cfg(feature = "aws-auth")] | ||
mod auth; | ||
mod no_auth; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are split into two separate modules to avoid including conditional compilation statements within the examples. Although we've talked about containing our examples in the top-level tests
directory, I needed to include these ones here instead because the tests
directory does not follow the module structure and therefore does not permit conditional compilation of an entire file.
|
||
// Runs a ping operation on the "db" database and returns the response. | ||
async fn handler_create_client(_: LambdaEvent<Value>) -> Result<Value, lambda_runtime::Error> { | ||
let uri = std::env::var("MONGODB_URI").unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
our URI for the AWS auth tests is configured a little differently than what is done for MONGODB_CLIENT
so this uses the URI set for the tests directly.
#[cfg_attr(feature = "tokio-runtime", tokio::test(flavor = "multi_thread"))] | ||
#[cfg_attr(feature = "async-std-runtime", async_std::test)] | ||
async fn test_handler() { | ||
if std::env::var("MONGODB_API_VERSION").is_ok() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A similar URI configuration issue -- it didn't seem super important to get versioned API coverage here so I just skipped the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Adds examples for using the driver with AWS Lambda. The examples are based off of this blog post and this example (thank you @pkdone!).
I've verified that these examples work by running them manually in Lambda.