retry

package
v0.0.0-...-9994f1b Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package retry provides retry methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LimitCount

func LimitCount(ctx context.Context, count int, interval time.Duration, f func() error, opName string) (err error)

LimitCount retries execute function with limit by numbers attempts.

Example: Check if device is reachable, only try 5 times with interval 2 seconds.

return retry.LimitCount(ctx, 5, 2*time.Second, func() error {
	return  <-- return err if device is not reachable.
}, "check if a device is reachable")

func LoopBreakTag

func LoopBreakTag() errors.BoolTag

LoopBreakTag returns tags to break to retry loop per request.

func WithTimeout

func WithTimeout(ctx context.Context, interval, duration time.Duration, f func() error, opName string) (err error)

WithTimeout retries execute function in giving time duration.

Example: Check if device is reachable, try during 1 hour with intervals 2 seconds.

return retry.WithTimeout(ctx, time.Hour,  2*time.Second, func() error {
	return  <-- return err if device is not reachable.
}, "check if a device is reachable")

Types

This section is empty.

Jump to

Keyboard shortcuts

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