Skip to content
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

fix(docs): add an operation polling example #2186

Merged
merged 5 commits into from
Sep 25, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -84,4 +84,38 @@
// fmt.Println("Domain: %s", aErr.Domain())
// }
// }
//
// # Polling Operations
//
// If an API call returns an Operation, that means it could take some time to
// complete the work initiated by the API call. Applications that are interested
// in the end result of the operation they initiated should wait until the
// Operation.Done field indicates it is finished. To do this, use the service's
// Operation client, and a loop, like so:
//
noahdietz marked this conversation as resolved.
Show resolved Hide resolved
// op, err := myApiClient.CalculateFoo().Do()
// if err != nil {
// // handle err
// }
//
// operationsService = NewOperationsService(myApiClient)
// for {
// if op.Done {
// break
// }
// // not done, sleep then poll again
// time.Sleep(1 * time.Second)
noahdietz marked this conversation as resolved.
Show resolved Hide resolved
//
// op, err := operationsService.Get(op.Name).Do()
// if err != nil {
// // handle error
// }
// }
//
// if op.Error != nil {
// // handle operation err
// }
//
// // Do something with the response
// fmt.Println(op.Response)
package api