Popularity
1.0
Declining
Activity
6.4
Declining
10
1
1

Programming language: Go
License: MIT License
Tags: Retry     Go Tools     Package     Golang    

retry alternatives and similar packages

Based on the "Go Tools" category.
Alternatively, view retry alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of retry or a related project?

Add another 'Go Tools' Package

README

PkgGoDev License [Go Version](go.mod) Tag

Go Report Card Maintainability Test Coverage

retry

Small, full-featured, 100% test-covered retry package for golang

features

  • small (~200 sloc), 100% test-covered codebase
  • fully-customizable, you can specify number of retries, sleep (and sleep-jitter) between them and stdlog verbosity
  • three ways to retry - single function, chain (one-by-one) and parallel execution

examples

simple

import (
    "log"

    "github.com/s0rg/retry"
)


    try := retry.New()

    // single
    if err := try.Single("single-func", func() error {
        return initSomeResource()
    }); err != nil {
        log.Fatal("retry:", err)
    }

with config

import (
    "log"
    "time"

    "github.com/s0rg/retry"
)

    try := retry.New(
        retry.Count(5),
        retry.Parallelism(2),
        retry.Sleep(time.Second*3),
        retry.Jitter(time.Second/2),
        retry.Verbose(true),
    )

    var (
        dbh *sql.DB
        kaf *kafka.Conn
        red *redis.Conn
    )

    steps := []retry.Step{
        {"database", func() (err error) {
            dbh, err = sql.Open(...)

            return
        }},
        {"kafka", func() (err error) {
            kaf, err = kafka.Connect(...)

            return
        }},
        {"redis", func() (err error) {
            red, err = redis.Connect(...)

            return
        }},
    }

    // parallel execution
    if err := try.Parallel(steps...); err != nil {
        log.Fatal("retry:", err)
    }

    // at this point all tree resources will be avialaible


*Note that all licence references and agreements mentioned in the retry README section above are relevant to that project's source code only.