Skip to content

Commit

Permalink
feat: rollout generated waiters for ec2 (#2717)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucix-aws authored Jul 23, 2024
1 parent 91e8bcc commit 30a39ba
Show file tree
Hide file tree
Showing 29 changed files with 876 additions and 1,149 deletions.
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(
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

0 comments on commit 30a39ba

Please sign in to comment.