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 ¶
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.
Click to show internal directories.
Click to hide internal directories.