-
Notifications
You must be signed in to change notification settings - Fork 243
Add client user guide for smithy java #2522
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
dd2cc72
Add client user guide for smithy java
hpmellema ec51713
Apply suggestions from code review
hpmellema 8dc4b8a
Apply suggestions from code review
hpmellema 1020b41
Update docs/source-2.0/java/client/configuration.rst
hpmellema 39700ca
Apply suggestions from code review
hpmellema 911b44a
Update based on PR feedback
hpmellema 11d1ca0
Capitalization fixes
hpmellema d84cccd
Additional updates based on feedback
hpmellema 3c3f2e8
Apply suggestions from code review
hpmellema 9c179ac
Even more fixes
hpmellema ebbe788
Fix bad indent
hpmellema af5dabe
Apply suggestions from code review
hpmellema 9c95855
Apply suggestions from code review
hpmellema 091ca6d
Apply suggestions from code review
hpmellema f6b76c8
Apply suggestions from code review
hpmellema fab1a33
Apply suggestions from code review
hpmellema 34a560f
Address PR feedback
hpmellema eae43e3
Remove reference to exchanges
hpmellema File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| ==================== | ||
| Codegen Integrations | ||
| ==================== | ||
|
|
||
| Smithy Java provides a number of client codegen integrations that modify the code generated by the client codegen plugin. | ||
|
|
||
| -------------- | ||
| Waiter Codegen | ||
| -------------- | ||
|
|
||
| .. warning:: | ||
|
|
||
| Only synchronous waiters are supported at this time. | ||
|
|
||
| :ref:`Waiters <waiters>` are a client-side abstraction used to poll a resource until a desired state is reached, | ||
| or until it is determined that the resource will never enter a desirable end state. | ||
| Waiters can be defined in the Smithy model using the ``smithy.waiters#waitable`` trait. | ||
|
|
||
| For example: | ||
|
|
||
| .. code-block:: smithy | ||
| :caption: model.smithy | ||
|
|
||
| use smithy.waiters#waitable | ||
|
|
||
| @waitable( | ||
| BucketExists: { | ||
| documentation: "Wait until a bucket exists" | ||
| acceptors: [ | ||
| { | ||
| state: "success" | ||
| matcher: { | ||
| success: true | ||
| } | ||
| } | ||
| { | ||
| state: "retry" | ||
| matcher: { | ||
| errorType: "NotFound" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ) | ||
| operation HeadBucket { | ||
| input: HeadBucketInput | ||
| output: HeadBucketOutput | ||
| errors: [NotFound] | ||
| } | ||
|
|
||
| The waiter-codegen integration can be used to automatically generate waiters from waitable trait | ||
| definitions in your Smithy model. To add the integration to your project (using the Smithy Gradle plugins): | ||
|
|
||
| .. code-block:: kotlin | ||
| :caption: build.gradle.kts | ||
|
|
||
| dependencies { | ||
| // Add codegen integration as a smithy-build dependency so it can be | ||
| // discovered by the client codegen plugin | ||
| smithyBuild("software.amazon.smithy.java.codegen:waiters:__smithy_java_version__") | ||
|
|
||
| // Add waiters core package as a runtime dependency | ||
| implementation("software.amazon.smithy.java:waiters:__smithy_java_version__") | ||
| } | ||
|
|
||
| This will cause your client code generator to create a waiter container class call ``<ServiceName>Waiters`` | ||
hpmellema marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| in your generated client package. This container provides a method per waiter defined in your smithy model | ||
hpmellema marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| that returns a pre-configured ``Waiter``` instance base on the configuration set in your Smithy model. | ||
hpmellema marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| You can get an instance of this waiter container for a client by calling the ``waiters()`` method added | ||
| to clients by this integration. | ||
hpmellema marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| .. code-block:: java | ||
|
|
||
| // Get the generated waiter container | ||
| var waiters = client.waiters(); | ||
| // Get the configurable waiter from the container | ||
| var orderCompletedWaiter = waiters.orderCompleted(); | ||
| // Wait for up to 2 seconds for the waiter to complete. | ||
| orderCompletedWaiter.wait(input, Duration.ofSeconds(2); | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.