retry

package
v0.0.0-...-b89eba7 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Report

type Report struct {
	Name        string
	Result      bool
	Times       int
	SumDuration time.Duration
	Errs        []error
}

Report 尝试重试的报告 Result为函数执行结果,Times为尝试次数, Duration为函数执行时间,SumDuration为总执行时间, Errs为函数执行错误记录

func (*Report) Error

func (report *Report) Error() string

type Try

type Try struct {
	Name     string
	F        func() error
	Duration time.Duration
	MaxTimes int
}

Try 尝试重试函数,如果函数执行失败,则延长时间重试 name: 重试任务名称, F: 需要重试的函数, Duration 默认延迟重试时间, MaxTimes 最大重试次数

func NewTry

func NewTry(name string, f func() error, d time.Duration, maxTimes int) *Try

func (Try) Run

func (try Try) Run() <-chan Report

Run 开始尝试重试,返回chan可以用于接收尝试报告

Jump to

Keyboard shortcuts

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