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

chore(docs/tests): SQSExtended test model (example of polymorph library calling an AWS service) #666

Merged
merged 53 commits into from
Oct 31, 2024

Conversation

robin-aws
Copy link
Contributor

@robin-aws robin-aws commented Oct 24, 2024

Description of changes:

Adds a test model intended as an example of how to build a thick client using polymorphing, in this case adding a very common client-side operation for AWS SQS. My intention was to make this a smithy init template, but as it was significant work to get this example working I'm locking it down in CI first, then will find a way to make a template from it while still testing it.

Made several fixes and improvements to get this working in Java and make progress in other languages:

  • Added a aws.polymorph#localService$configRequired parameter, defaulting to false. Previously all local services had to provide a default factory method for config structures, but this isn't always reasonable. For SQSExtended you really have to provide an underlying SQS client, and there's no sensible default value for an allocated service client.
  • Found that Dafny only requires a ...types.__default.java file if the {:extern} module has any subset types declared. To move closer to being able to eventually GENERATE ALL THE THINGS, added a dummy subset type in the polymorph_dafny output so this is always required, and included this empty file when doing --generate client-constructors. This isn't really breaking since all substantial polymorph libraries have lots of constraints in their models and hence subset types declared.
  • Generalized the BinarySetAttributeValue handling to use SdkBytes correctly to all lists of blobs.
  • Added a dafnyError case for ToNative on an arbitrary top-level service error (currently being patched in manually in the MPL).
  • Fixed more naming shenanigans on error types in Java (and deleted a patch that was then no longer necessary).
  • Added more SQS permissions to the CI role (already applied to the stack).
  • Deleted some checked-in files that aren't necessary any more.

Also added a Setup section to the main README, since there are extra steps now.

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

…obin-aws/sqs-extended-test-model

# Conflicts:
#	TestModels/aws-sdks/ddb-lite/model/ComAmazonawsDynamodbTypes.dfy
#	TestModels/aws-sdks/kms-lite/model/ComAmazonawsKmsTypes.dfy
#	codegen/smithy-dafny-codegen-test/src/test/java/software/amazon/polymorph/smithydotnet/DotnetTestModels.java
#	codegen/smithy-dafny-codegen-test/src/test/java/software/amazon/polymorph/smithyjava/JavaTestModels.java
@robin-aws robin-aws marked this pull request as ready for review October 30, 2024 17:02
@robin-aws robin-aws requested a review from a team as a code owner October 30, 2024 17:02
@robin-aws robin-aws changed the title Robin aws/sqs extended test model chore(docs/tests): SQSExtended test model (example of polymorph library calling an AWS service) Oct 30, 2024
…obin-aws/sqs-extended-test-model

# Conflicts:
#	TestModels/aws-sdks/ddb-lite/model/ComAmazonawsDynamodbTypes.dfy
#	TestModels/aws-sdks/kms-lite/model/ComAmazonawsKmsTypes.dfy
Copy link
Contributor

@seebees seebees left a comment

Choose a reason for hiding this comment

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

This is super great!
Might have been better as multiple PRs, but I'm not sure if that is worth the overhead :)

for i := 0 to |messages| {
var message := messages[i];
// TODO: Propogate error instead of terminating
var receiptHandle :- expect message.ReceiptHandle;
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 should just be able to MapFailure here. The smithy-dafny error type should have a joining error that should just work.

non-blocking point :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup agreed. I'll address that when I follow up with adding more target languages.

@robin-aws robin-aws merged commit 31d61b1 into main-1.x Oct 31, 2024
80 checks passed
@robin-aws robin-aws deleted the robin-aws/sqs-extended-test-model branch October 31, 2024 18:42
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