Logo

0x5a.live

for different kinds of informations and explorations.

GitHub - shafreeck/retry: A pretty simple library to ensure your work to be done

A pretty simple library to ensure your work to be done - shafreeck/retry

Visit SiteGitHub - shafreeck/retry: A pretty simple library to ensure your work to be done

GitHub - shafreeck/retry: A pretty simple library to ensure your work to be done

A pretty simple library to ensure your work to be done - shafreeck/retry

Powered by 0x5a.live ๐Ÿ’—

Retry is a pretty simple library to ensure your work to be done

godoc

Go Report Card cover.run

Features

  • Retry to run a workflow(Ex. rpc or db access)
  • Customize backoff strategy
  • Retry accoding to your type of error

Examples

func ExampleEnsure() {
    r := New()
    ctx, cancel := context.WithTimeout(context.Background(), time.Second)
    defer cancel()

    err := r.Ensure(ctx, func() error {
        resp, err := http.Get("http://www.example.com")
        // Get error can be retried
        if err != nil {
            log.Println(err)
            return Retriable(err)
        }
        log.Println(resp)

        buf := bytes.NewBuffer(nil)
        resp, err = http.Post("http://example.com/upload", "image/jpeg", buf)
        // Post error should not be retried
        if err != nil {
            return err
        }
        log.Println(resp)
        return nil
    })
    if err != nil {
        log.Fatal(err)
    }
}

GoLang Resources

are all listed below.

Resources

listed to get explored on!!

Made with โค๏ธ

to provide different kinds of informations and resources.