Skip to content
Retrying made simple and easy for golang 🔁
Go Makefile
Branch: master
Clone or download
Latest commit 5981a38 Dec 14, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
_examples Change pkg typo Jun 9, 2017
LICENSE Add license Dec 13, 2017
Makefile Let"s fly Jun 4, 2017
README.md Improve docs Dec 14, 2017
retry.go Fix misspell Dec 14, 2017
retry_test.go Fix lint and table tests ftw Dec 13, 2017

README.md

retry-go

  • Retrying made simple and easy for golang.

Installation

go get -u github.com/rafaeljesus/retry-go

Usage

Do

package main

import (
  "time"

  "github.com/rafaeljesus/retry-go"
)

func main() {
  attempts := 3
  sleepTime := time.Second*2
  if err := retry.Do(func() error {
    return work()
  }, attempts, sleepTime); err != nil {
    // Retry failed
  }
}

DoHTTP

package main

import (
  "time"

  "github.com/rafaeljesus/retry-go"
)

func main() {
  attempts := 3
  sleepTime := time.Second*2
  if err := retry.DoHTTP(func() (*http.Response, error) {
    return makeRequest()
  }, attempts, sleepTime); err != nil {
    // Retry failed
  }
}

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

Badges

Build Status Go Report Card Go Doc


GitHub @rafaeljesus  ·  Medium @_jesus_rafael  ·  Twitter @_jesus_rafael

You can’t perform that action at this time.