Skip to content

Conversation

@maxday
Copy link
Member

@maxday maxday commented Nov 7, 2023

Issue: #228

Description of changes:
Add an example using Cargo worskpace feature to:

  • be able to have multiple (here 2) functions in the same project
  • be able to share code (here a pizza Struct)
  • use this shared Struck to validate a SQS message type

By submitting this pull request

  • I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • I confirm that I've made a best effort attempt to update all relevant documentation.

tracing = "0.1.40"
tracing-subscriber = "0.3.17"

#aws depdencies
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: typo

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks! fixed

Comment on lines +9 to +22
[dependencies]
#tracing
tracing = "0.1.40"
tracing-subscriber = "0.3.17"

#aws dependencies
aws-config = "0.57.1"
aws-sdk-config = "0.35.0"
aws-sdk-sqs = "0.35.0"

#lambda runtime
lambda_runtime = "0.8.1"
serde_json = "1.0.108"
tokio = { version = "1", features = ["macros"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

to fully show the possibilities of the workspace model, you might consider putting these dependencies that are shared between producer and consumer in workspace dependencies.

https://doc.rust-lang.org/nightly/cargo/reference/workspaces.html#the-dependencies-table

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, I just wanted to show how to share a struct, so I feel that this change might confuse the user? WDYT? I don't have a strong opinion here so let me know if you want me to make that change :)

Copy link
Contributor

Choose a reason for hiding this comment

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

i don't feel strongly about it

Comment on lines 32 to 36
// create our SQS client
let config = aws_config::from_env().load().await;

// send our message to SQS
let client = aws_sdk_sqs::Client::new(&config);
Copy link
Contributor

Choose a reason for hiding this comment

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

np: comments are a bit mis-aligned here. you say "create our SQS client" when you're just creating the config, then say "send our message" when you create the SQS client.

actually, do you think it makes sense to model the SQS client as shared state here? that'd be best practice.

Copy link
Member Author

Choose a reason for hiding this comment

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

you're totally right, I've moved it to a shared state!

@greenwoodcm
Copy link
Contributor

thanks for the submission!

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.

Thanks for the example!

@calavera calavera merged commit 2a82ba7 into aws:main Nov 7, 2023
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.

3 participants