Skip to content

Make waiters data driven and available to dynamic clients - #1476

Merged
mtdowling merged 1 commit into
mainfrom
data-driven-waiters
Dec 1, 2026
Merged

mtdowling merged 1 commit into
mainfrom
data-driven-waiters

Conversation

@mtdowling

Copy link
Copy Markdown
Member

Summary

Waiters are now interpreted from their modeled smithy.waiters#waitable definitions 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 @waitable from an operation schema. Dynamic client schemas carry the trait, so this works without generated code:
    var operation = client.getOperation("GetBuild");
    Waiter<StructDocument, StructDocument> waiter = Waiter.fromModel(
            (input, override) -> (StructDocument) client.call("GetBuild", input, override),
            operation,
            "BuildDone");
  • 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.json next to the container:

public Waiter<DescribeInstancesInput, DescribeInstancesOutput> instanceRunning() {
    return Waiter.<DescribeInstancesInput, DescribeInstancesOutput>fromResource(
            client::describeInstances,
            AmazonEC2Waiter.class,
            "InstanceRunning");
}

Generated waiters no longer carry @Deprecated or deprecation Javadoc. Removing the annotation is source and binary compatible.

For EC2 (43 waiters), AmazonEC2Waiter goes 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:

  • Swapped delays. Generated code called BackoffStrategy.getDefault(maxDelay, minDelay), but the parameters are (min, max). With the default 120s/2s delays, every poll waited about 120s.
  • Dropped and reordered acceptors. The generator stored acceptors in a map keyed by state, so repeated states were lost and order was not preserved. EC2's InstanceRunning kept only one of its three failure acceptors (stopping, not shutting-down or terminated).
  • Inverted allStringEquals. It matched only when no element equaled the expected value.
  • Backoff formula. The default strategy computed (2 * minDelay)^attempt instead of the specified minDelay * 2^(attempt - 1).
  • Waiters from other services. The generator emitted waiters for every @waitable operation in the model, not just operations in the generated service.
  • Build logic. mergeItServiceFiles declared 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: allStringEquals and anyStringEquals.
  • DefaultBackoffStrategyTest: the spec growth curve.
  • Codegen WaiterTest (integ): a generated client waits against the echo server, including two failure acceptors evaluated before a success acceptor.
  • ./gradlew build passes, including live-benchmarks, which compiles waiters generated from AWS models.

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.
@github-actions

Copy link
Copy Markdown
Contributor

Codegen size report

Code generated for 439 AWS service models (aws-api-models 1.0.355) with modes client server; sizes count client output only. Compiled with javac 25.0.5.1+2-LTS (--release 21 -g -proc:none -nowarn). Jar size is the size of a jar holding the compiled classes and generated resources at default compression.

Metric Base PR Change
Largest jar increase: database-migration-service 2.13 MB 2.13 MB +125 B (+0.01%)
Largest jar decrease: ec2 16.49 MB 16.49 MB -290 B (-0.00%)
Total jar size 433.35 MB 433.34 MB -2.8 KB (-0.00%)
Average jar size 1015.4 KB 1015.4 KB -7 B (-0.00%)
Median jar size (p50) 607.6 KB 607.6 KB 0
Class bytes 1.06 GB 1.06 GB -128.4 KB (-0.01%)
Classes 271,582 271,582 0
Source bytes 825.15 MB 825.04 MB -108.1 KB (-0.01%)
Source files 109,598 109,598 0

Totals cover the 437 services that compile on both base and PR. Known failures excluded: clouddirectory, deadline. Listed as known failures but compiling, so the entries can be removed: timestream-query, timestream-write.

Largest changes by service

79 of 437 services changed jar size.

Service Base PR Change
ec2 16.49 MB 16.49 MB -290 B (-0.00%)
acm 1022.4 KB 1022.2 KB -147 B (-0.01%)
database-migration-service 2.13 MB 2.13 MB +125 B (+0.01%)
dynamodb 1.71 MB 1.71 MB -117 B (-0.01%)
schemas 397.9 KB 397.8 KB -114 B (-0.03%)
dsql 313.8 KB 313.7 KB -113 B (-0.04%)
lambda-web 406.2 KB 406.1 KB -111 B (-0.03%)
lambda 2.18 MB 2.18 MB -109 B (-0.00%)
resiliencehubv2 1.77 MB 1.77 MB -109 B (-0.01%)
iam 2.36 MB 2.36 MB +108 B (+0.00%)
inspector2 2.84 MB 2.84 MB -108 B (-0.00%)
acm-pca 519.2 KB 519.1 KB -95 B (-0.02%)
kinesis 1.07 MB 1.07 MB -94 B (-0.01%)
iotsitewise 3.09 MB 3.09 MB -93 B (-0.00%)
b2bi 884.9 KB 884.8 KB -87 B (-0.01%)
`ec2`: by category
Category Base jar bytes PR jar bytes Change Base files PR files
structure 9.83 MB 9.83 MB 0 5,326 5,326
enum 2.83 MB 2.83 MB 0 4,942 4,942
operation 715.0 KB 715.0 KB 0 830 830
schemas 569.3 KB 569.3 KB 0 35 35
client 177.8 KB 176.0 KB -1.7 KB (-0.98%) 7 7
serde 175.6 KB 175.6 KB 0 34 34
resources 605 B 1.9 KB +1.3 KB (+214.88%) 2 3
error 474 B 474 B 0 1 1
`ec2`: largest changes by class

1 top-level classes added, 0 removed. Sizes are deflated jar bytes.

Class Base PR Change
client.AmazonEC2Waiter 5.6 KB 3.9 KB -1.7 KB (-31.09%)
gen/amazonec2/client/AmazonEC2Waiter.waiters.json added 1.3 KB +1.3 KB

Base: main at a94785c. PR: 90b7d90 merged into the base. Workflow run.

@mtdowling
mtdowling merged commit 76f1fc3 into main Dec 1, 2026
10 checks passed
@mtdowling
mtdowling deleted the data-driven-waiters branch December 1, 2026 02:54
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