An open API service indexing awesome lists of open source software.

https://github.com/squat/retry

A utility library for retrying operations
https://github.com/squat/retry

Last synced: about 1 year ago
JSON representation

A utility library for retrying operations

Awesome Lists containing this project

README

          

# Retry

[![Build Status](https://travis-ci.org/squat/retry.svg?branch=master)](https://travis-ci.org/squat/retry)
[![Go Report Card](https://goreportcard.com/badge/github.com/squat/retry)](https://goreportcard.com/report/github.com/squat/retry)
[![GoDoc](https://godoc.org/github.com/squat/retry?status.png)](https://godoc.org/github.com/squat/retry)

## Usage
```go
b := ConstantBackOff{5 * time.Second}
operation := func() error {
// ... do some work
return nil
}
r := NewRetrier(operation, b)
r.Notify(func(m Message) {
if m.Error != nil {
fmt.Println(m.Error)
}
})
// Wait until the operation is done.
r.Done()
fmt.Println("All done!")
```