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

feat: rollout generated waiters for ec2 #2717

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changelog/3862dfedda7e4cf9b8593de8ac95a77e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "3862dfed-da7e-4cf9-b859-3de8ac95a77e",
"type": "feature",
"description": "Switch to new waiter matching implementation, which conveys a slight performance boost and removes the need for the go-jmespath runtime dependency.",
"modules": [
"service/ec2"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@

import software.amazon.smithy.aws.go.codegen.AwsGoDependency;
import software.amazon.smithy.codegen.core.Symbol;
import software.amazon.smithy.codegen.core.SymbolProvider;
import software.amazon.smithy.go.codegen.GoDelegator;
import software.amazon.smithy.go.codegen.GoSettings;
import software.amazon.smithy.go.codegen.GoCodegenContext;
import software.amazon.smithy.go.codegen.SmithyGoDependency;
import software.amazon.smithy.go.codegen.integration.Waiters;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.shapes.ShapeId;

import static software.amazon.smithy.go.codegen.GoWriter.goTemplate;
import static software.amazon.smithy.go.codegen.SymbolUtils.buildPackageSymbol;
Expand All @@ -40,10 +39,16 @@ public Set<Symbol> getAdditionalClientOptions() {
}

@Override
public void writeAdditionalFiles(GoSettings settings, Model model, SymbolProvider symbolProvider, GoDelegator goDelegator) {
super.writeAdditionalFiles(settings, model, symbolProvider, goDelegator);
public boolean enabledForService(Model model, ShapeId service) {
return !AwsWaiters2.PHASED_ROLLOUT_SERVICES.contains(service);
}

@Override
public void writeAdditionalFiles(GoCodegenContext ctx) {
super.writeAdditionalFiles(ctx);

goDelegator.useFileWriter("api_client.go", settings.getModuleName(), goTemplate("""
// happens regardless of enabledForService() == true - so AwsWaiters2 can use it
ctx.writerDelegator().useFileWriter("api_client.go", ctx.settings().getModuleName(), goTemplate("""
func addIsWaiterUserAgent(o *Options) {
o.APIOptions = append(o.APIOptions, func(stack $stack:P) error {
ua, err := getOrAddRequestUserAgent(stack)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package software.amazon.smithy.aws.go.codegen.customization;

import software.amazon.smithy.codegen.core.Symbol;
import software.amazon.smithy.go.codegen.integration.Waiters2;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.shapes.ShapeId;

import java.util.List;
import java.util.Set;

import static software.amazon.smithy.go.codegen.SymbolUtils.buildPackageSymbol;

public class AwsWaiters2 extends Waiters2 {
public static final List<ShapeId> PHASED_ROLLOUT_SERVICES = List.of(
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] likely irrelevant due to small n, but this is definitely a use case for a Set

ShapeId.from("com.amazonaws.ec2#AmazonEC2")
);

@Override
public Set<Symbol> getAdditionalClientOptions() {
return Set.of(buildPackageSymbol("addIsWaiterUserAgent"));
}

@Override
public boolean enabledForService(Model model, ShapeId service) {
return PHASED_ROLLOUT_SERVICES.contains(service);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
software.amazon.smithy.aws.go.codegen.customization.AwsWaiters
software.amazon.smithy.aws.go.codegen.customization.AwsWaiters2
software.amazon.smithy.aws.go.codegen.customization.AwsPaginators
software.amazon.smithy.aws.go.codegen.customization.auth.BackfillSigV4ATrait
software.amazon.smithy.aws.go.codegen.AddProtocols
Expand Down
59 changes: 22 additions & 37 deletions service/ec2/api_op_DescribeBundleTasks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

146 changes: 53 additions & 93 deletions service/ec2/api_op_DescribeConversionTasks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading