Repository navigation
Make waiters data driven and available to dynamic clients - #1476
Merged
Merged
Conversation
Waiters are now interpreted from their modeled definitions at runtime instead of being generated as matcher code. Runtime: - Waiter.fromDefinition builds a waiter from a smithy.waiters Waiter definition, evaluating acceptors in modeled order. - Waiter.fromModel reads the waitable trait from an operation schema, so dynamic clients can use modeled waiters. - Waiter.fromResource (internal) loads definitions bundled next to a class, once, the first time one of its waiters is requested. Codegen: - Generated waiter containers keep their public methods. Each method delegates to Waiter.fromResource, and the definitions are written to a <Container>.waiters.json resource next to the container. - Generated waiters no longer carry @deprecated or deprecation Javadoc. Bug fixes: - Generated waiters passed delays to BackoffStrategy.getDefault as (max, min), so they waited about maxDelay between every poll. - Acceptors were collected into a map keyed by state, which dropped repeated states and lost modeled evaluation order. - Waiters were generated for every waitable operation in the model, not just operations in the generated service. - allStringEquals matched only when no element equaled the expected value. - The default backoff computed (2 * minDelay)^attempt instead of the specified minDelay * 2^(attempt - 1). - The integ resource merge task declared no inputs, so newly generated resources never reached the integration test classpath.
Contributor
Codegen size reportCode generated for 439 AWS service models (aws-api-models 1.0.355) with modes
Totals cover the 437 services that compile on both base and PR. Known failures excluded: Largest changes by service79 of 437 services changed jar size.
`ec2`: by category
`ec2`: largest changes by class1 top-level classes added, 0 removed. Sizes are deflated jar bytes.
Base: |
sugmanue
approved these changes
Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Waiters are now interpreted from their modeled
smithy.waiters#waitabledefinitions at runtime instead of being generated as matcher code. Dynamic clients can use modeled waiters, and generated waiters become thin wrappers over the same runtime path. Reading the old path turned up several bugs, which are fixed here.Runtime (
client-waiters)Waiter.fromDefinition(pollFn, definition)builds a waiter from a modeled definition. Acceptors are evaluated in modeled order, and the modeled delays configure the backoff.Waiter.fromModel(pollFn, operation, name)reads@waitablefrom an operation schema. Dynamic client schemas carry the trait, so this works without generated code:Waiter.fromResource(pollFn, owner, name)(@SmithyInternalApi) loads definitions bundled next to a class. The resource is read once per class, the first time one of its waiters is requested.Codegen
Generated waiter containers keep every public method signature. Each method now delegates to the runtime, and the definitions are written to
<Container>.waiters.jsonnext to the container:Generated waiters no longer carry
@Deprecatedor deprecation Javadoc. Removing the annotation is source and binary compatible.For EC2 (43 waiters),
AmazonEC2Waitergoes from 5,725 to 5,245 compressed bytes in the jar (3,945 class + 1,300 JSON), and from 23,795 to 18,814 class bytes.Bug fixes
These change runtime behavior of existing generated waiters:
BackoffStrategy.getDefault(maxDelay, minDelay), but the parameters are(min, max). With the default 120s/2s delays, every poll waited about 120s.InstanceRunningkept only one of its three failure acceptors (stopping, notshutting-downorterminated).allStringEquals. It matched only when no element equaled the expected value.(2 * minDelay)^attemptinstead of the specifiedminDelay * 2^(attempt - 1).@waitableoperation in the model, not just operations in the generated service.mergeItServiceFilesdeclared no inputs, so newly generated resources never reached the integration test classpath.Testing
WaiterDefinitionsTest: definition-driven success, failure, and retry; acceptor order with repeated states; bundled resources, including missing resources and unknown waiter names; dynamic clients resolving waiters from the model.ComparatorTest:allStringEqualsandanyStringEquals.DefaultBackoffStrategyTest: the spec growth curve.WaiterTest(integ): a generated client waits against the echo server, including two failure acceptors evaluated before a success acceptor../gradlew buildpasses, includinglive-benchmarks, which compiles waiters generated from AWS models.