retry

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2022 License: MIT Imports: 0 Imported by: 1

README

retry

Simple library for retry function on error

Installation

go get github.com/IAkumaI/retry

Usage

package main

import (
	"errors"
	"github.com/IAkumaI/retry"
	"log"
)

func main() {
	// Function will be called until no errors up to 3 times
	// If after 3 runs there is still error,
	// this error will be returned by Do method
	err := retry.Do(3, func(retryCount int) error {
		log.Println("retryCount", retryCount)

		if retryCount < 2 {
			return errors.New("test error")
		}

		return nil
	})

	if err != nil {
		panic(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(maxRetry int, fn func(int) error) (err error)

Do Run function until no errors returned or maxRetry reached There is no delays between runs

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL