Skip to content

Commit

Permalink
fix retry example
Browse files Browse the repository at this point in the history
  • Loading branch information
cenkalti committed Dec 18, 2024
1 parent 7b9bd02 commit b41b52b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@ package backoff

import (
"context"
"fmt"
"log"
)

func ExampleRetry() {
// An operation that may fail.
operation := func() (bool, error) {
return true, nil
operation := func() (string, error) {
return "hello", nil
}

_, err := Retry(context.TODO(), operation, WithBackOff(NewExponentialBackOff()))
val, err := Retry(context.TODO(), operation, WithBackOff(NewExponentialBackOff()))
if err != nil {
// Handle error.
return
}

// Operation is successful.

fmt.Println(val)
// Output: hello
}

func ExampleTicker() {
Expand Down

0 comments on commit b41b52b

Please sign in to comment.