Skip to content

feat: move common middlewares to shared addCommonMiddlewares#674

Open
Tongs2000 wants to merge 2 commits into
mainfrom
feat-invoke-operation-refactor
Open

feat: move common middlewares to shared addCommonMiddlewares#674
Tongs2000 wants to merge 2 commits into
mainfrom
feat-invoke-operation-refactor

Conversation

@Tongs2000

@Tongs2000 Tongs2000 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Issue: aws/aws-sdk-go-v2#3321

Move common middlewares (those identical across every operation) into a shared addCommonMiddlewares method on Client, called from invokeOperation. Per-operation addOperation*Middlewares functions now only register what is truly unique(serializer, deserializer, predicate-scoped customizations).

Results in ~47% reduction in per-operation function compiled size. SQS benchmark: ~2,550 bytes saved per operation, ~57 KB net savings across 23 operations.

Companion PR in aws-sdk-go-v2 will bump SMITHY_GO_CODEGEN_VERSION and mark additional AWS-specific plugins as common.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Tongs2000 Tongs2000 force-pushed the feat-invoke-operation-refactor branch from 3a10e51 to 1f79d32 Compare June 4, 2026 21:11
@Tongs2000 Tongs2000 marked this pull request as ready for review June 5, 2026 15:32
@Tongs2000 Tongs2000 requested review from a team as code owners June 5, 2026 15:32
if err := addProtocolFinalizerMiddlewares(stack, options, operation); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}""");
writer.addUseImports(SmithyGoDependency.FMT);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: add import before use it

.resolvedFunction(SymbolUtils.createValueSymbolBuilder(REGISTER_MIDDLEWARE).build())
.useClientOptions()
.build())
.isCommon(true)

@wty-Bryant wty-Bryant Jun 5, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so there might be some other operations shared middlewares (e.g. addRetry, req/resp logging etc) that can be marked as common imo, you may already include some of them in go v2 pr, so it will help after you created the bumped go v2 pr (ik it's hard to collect them all in single pr)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes — the other common middlewares (addRetry, addClientUserAgent, addRecursionDetection, etc.) are marked in the companion aws-sdk-go-v2 PR at aws/aws-sdk-go-v2 branch feat-invoke-operation-refactor. Only ClientLogger lives in smithy-go, the rest are AWS-specific integrations.

@Tongs2000 Tongs2000 force-pushed the feat-invoke-operation-refactor branch from 0df0cba to ee10944 Compare June 8, 2026 22:26
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