Rafaeljesus Retry Go Save

Retrying made simple and easy for golang :repeat:

Project README

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

Open Source Agenda is not affiliated with "Rafaeljesus Retry Go" Project. README Source: rafaeljesus/retry-go
Stars
48
Open Issues
2
Last Commit
5 years ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating