Skip to content

Commit

Permalink
add backoff
Browse files Browse the repository at this point in the history
  • Loading branch information
noahdietz committed Sep 25, 2023
1 parent d20b705 commit 79c0fac
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,32 @@
// Operation.Done field indicates it is finished. To do this, use the service's
// Operation client, and a loop, like so:
//
// import (
// gax "github.com/googleapis/gax-go/v2"
// )
//
// // existing application code...
//
// // API call that returns an Operation.
// op, err := myApiClient.CalculateFoo().Do()
// if err != nil {
// // handle err
// }
//
// operationsService = NewOperationsService(myApiClient)
// operationsService = myapi.NewOperationsService(myApiClient)
// pollingBackoff := gax.Backoff{
// Initial: time.Second,
// Max: time.Minute, // Max time between polling attempts.
// Multiplier: 2,
// }
// for {
// if op.Done {
// break
// }
// // not done, sleep then poll again
// time.Sleep(1 * time.Second)
//
// // not done, sleep with backoff, then poll again
// if err := gax.Sleep(ctx, pollingBackoff.Pause()); err != nil {
// // handle error
// }
// op, err := operationsService.Get(op.Name).Do()
// if err != nil {
// // handle error
Expand Down

0 comments on commit 79c0fac

Please sign in to comment.