-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Smithy generator for paginator #3690
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
base: main
Are you sure you want to change the base?
Conversation
...-codegen/src/main/java/com/amazonaws/util/awsclientsmithygenerator/generators/CppWriter.java
Show resolved
Hide resolved
0fd0691 to
661e748
Compare
| implementation("software.amazon.smithy:smithy-aws-traits:1.51.0") | ||
| implementation("software.amazon.smithy:smithy-waiters:1.51.0") | ||
| implementation("software.amazon.smithy:smithy-rules-engine:1.51.0") | ||
| implementation("software.amazon.smithy:smithy-aws-endpoints:1.51.0") |
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.
Why do we need this? It's not like we're going to be using smithy based endpoints rule traits right?
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.
Ah, this was from copying the pattern used in our codegen-workshop.
I will refactor the build script to use our existing pattern from smoke-test gen
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.
Smithy actually needs all the above dependencies, in the current set up we are not accepting any unknown traits
.../util/awsclientsmithygenerator/generators/pagination/PaginationCompilationTestGenerator.java
Outdated
Show resolved
Hide resolved
20097ca to
7433789
Compare
a426d02 to
03ae46d
Compare
generated/src/aws-cpp-sdk-dynamodb/include/aws/dynamodb/DynamoDBClientPagination.h
Outdated
Show resolved
Hide resolved
|
|
||
| namespace Aws { | ||
| namespace DynamoDB { | ||
| class DynamoDBClient; |
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.
instead of forward declaring DynamoDB why not have ScanPaginationTraits take a template parameter template <typename Client = ClientType> like you have on Invoke then the entire class is tempalted. You already pass DynamoDBClient as a template parameter in DynamoDBClientPagination.h
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.
Gotcha, changed the traits to template files instead
generated/src/aws-cpp-sdk-dynamodb/include/aws/dynamodb/DynamoDBClient.h
Show resolved
Hide resolved
| ListContributorInsightsPaginator(const Model::ListContributorInsightsRequest& request) { | ||
| return Aws::Utils::Pagination::PagePaginator<DerivedClient, Model::ListContributorInsightsRequest, | ||
| Pagination::ListContributorInsightsPaginationTraits>{ | ||
| std::shared_ptr<DerivedClient>(static_cast<DerivedClient*>(this), [](DerivedClient*) {}), request}; |
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.
likely isnt what we want to be doing, you are creating a shared point from this then have a custom deleter [](DerivedClient*) {} that does nothing when delete is called. you are essentially trying to fit this into a shared pointer without using the actual properties of shared.
consider
#include <iostream>
#include <thread>
template<typename crtp_t>
class thing {
public:
thing(crtp_t& ref) : ptr_(ref) {};
void do_something() {
ptr_.work();
}
private:
crtp_t& ptr_;
};
template <typename crtp_t>
class mixin {
public:
void operation() {
thing<crtp_t> operation_thing{*static_cast<crtp_t*>(this)};
operation_thing.do_something();
}
};
class widget : public mixin<widget> {
public:
void work() {
std::cout << "hello from class\n";
}
};
auto main() -> int {
widget w{};
w.operation();
return 0;
}which is long way of saying on PagePaginator make client a reference not a pointer
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.
Changed paginator.h to make client a reference instead
generated/tests/dynamodb-gen-tests/DynamoDBPaginationCompilationTests.cpp
Show resolved
Hide resolved
tests/aws-cpp-sdk-dynamodb-integration-tests/ScanPaginationIntegrationTest.cpp
Outdated
Show resolved
Hide resolved
| print(f"Code generation done, (re)generated {len(done)} packages.") # Including defaults and partitions | ||
|
|
||
| # Format generated client code | ||
| generated_clients = [service for service in self.c2j_models.keys()] |
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.
is this not needed in this code path anymore?
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.
Yup, we moved the clang formatting to tools/scripts/run_code_generation.py so it can run after all files have been generated instead of just c2j generated codes
| "cloudwatch-logs":"logs", | ||
| "directory-service":"ds", | ||
| "elasticsearch-service ":"es", | ||
| "elasticsearch-service":"es", |
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.
nit: whitespace change
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.
Original code had an inconsistency that made my custom parsing logic failed. I already fixed my custom parsing logic and went ahead to fix the inconsistency as well
| var model = context.getModel(); | ||
|
|
||
| // Handle legacy services without Smithy models | ||
| if (context.getProjectionName().endsWith(".mock")) { |
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.
how is ".mock" generated in the projection name?
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.
We have a small logic in tools/code-generation/smithy/cpp-codegen/build.gradle.kts that generates these projections that do not exist in smithy but does exist in coral so we can maintain backwards compatibility.
// Legacy services without full Smithy models - generate mock projections for base classes
val legacyServices = mapOf("importexport" to "ImportExport", "sdb" to "SimpleDB", "s3-crt" to "S3Crt")
legacyServices.forEach { (c2jName, serviceName) ->
if (filteredServiceList.isEmpty() || c2jName in filteredServiceList) {
val mockProjectionContents = Node.objectNodeBuilder()
.withMember("plugins", Node.objectNode()
.withMember("smithy-cpp-codegen", Node.objectNodeBuilder()
.withMember("c2jMap", Node.from(c2jMapStr))
.build()))
.build()
projectionsBuilder.withMember("$c2jName.mock", mockProjectionContents)
}
239688c to
fe3fc77
Compare
...m/amazonaws/util/awsclientsmithygenerator/generators/pagination/PaginationCodegenPlugin.java
Outdated
Show resolved
Hide resolved
...m/amazonaws/util/awsclientsmithygenerator/generators/pagination/PaginationCodegenPlugin.java
Outdated
Show resolved
Hide resolved
...m/amazonaws/util/awsclientsmithygenerator/generators/pagination/PaginationCodegenPlugin.java
Outdated
Show resolved
Hide resolved
...m/amazonaws/util/awsclientsmithygenerator/generators/pagination/PaginationCodegenPlugin.java
Show resolved
Hide resolved
.../main/java/com/amazonaws/util/awsclientsmithygenerator/generators/ClientCodegenSettings.java
Outdated
Show resolved
Hide resolved
...-codegen/src/main/java/com/amazonaws/util/awsclientsmithygenerator/generators/ShapeUtil.java
Outdated
Show resolved
Hide resolved
...amazonaws/util/awsclientsmithygenerator/generators/pagination/PaginationTraitsGenerator.java
Outdated
Show resolved
Hide resolved
e95e912 to
b68b5bb
Compare
… clients, service-specific patches, and integration tests for S3, EC2, and DynamoDB
…dessed some nits change codegen to create templated pagination traits instead of forward declaring addressed comment on making paginators with references instead of pointers change pagepaginator to paginator
b68b5bb to
ac53a13
Compare
ac53a13 to
3616995
Compare
Issue #, if available:
Description of changes:
Smithy-based code generator for paginators
Check all that applies:
Check which platforms you have built SDK on to verify the correctness of this PR.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.