Documentation
¶
Index ¶
- Constants
- func SetGlobalDefaultLogger(logger log.Logger)
- func SetGlobalInterruptChecker(checker GlobalInterruptChecker)
- type BreakPredicate
- type GlobalInterruptChecker
- type Loop
- func NewLoop(name string, attemptsQuantity int, wait time.Duration) *Loop
- func NewLoopWithParams(params Params) *Loop
- func NewLoopWithParamsOpts(opts ...ParamsBuilderOpt) *Loop
- func NewSilentLoop(name string, attemptsQuantity int, wait time.Duration) *Loop
- func NewSilentLoopWithParams(params Params) *Loop
- func NewSilentLoopWithParamsOpts(opts ...ParamsBuilderOpt) *Loop
- func (l *Loop) BreakIf(pred BreakPredicate) *Loop
- func (l *Loop) Run(task func() error) error
- func (l *Loop) RunContext(ctx context.Context, task func() error) error
- func (l *Loop) WithInterruptable(flag bool) *Loop
- func (l *Loop) WithLogger(logger log.Logger) *Loop
- func (l *Loop) WithShowError(flag bool) *Loop
- type Params
- type ParamsBuilderOpt
Constants ¶
const (
NotSetName = "Name not set"
)
Variables ¶
This section is empty.
Functions ¶
func SetGlobalDefaultLogger ¶
SetGlobalDefaultLogger Deprecated: global logger used for backward compatibility in dhctl with deprecated functions NewLoop and NewSilentLoop Please use NewLoopWithParams and NewSilentLoopWithParams
func SetGlobalInterruptChecker ¶
func SetGlobalInterruptChecker(checker GlobalInterruptChecker)
Types ¶
type BreakPredicate ¶
func IsErr ¶
func IsErr(err error) BreakPredicate
type GlobalInterruptChecker ¶
type GlobalInterruptChecker func() bool
type Loop ¶
type Loop struct {
// contains filtered or unexported fields
}
Loop retries a task function until it succeeded with number of attempts and delay between runs are adjustable.
func NewLoop ¶
NewLoop create Loop with features: - it is "verbose" loop — it prints messages through logboek. - this loop is interruptable by the signal watcher in tomb package. Deprecated: use NewLoopWithParams in futures versions NewLoop will take Params
func NewLoopWithParams ¶
func NewLoopWithParamsOpts ¶
func NewLoopWithParamsOpts(opts ...ParamsBuilderOpt) *Loop
func NewSilentLoop ¶
NewSilentLoop create Loop with features: - it is "silent" loop — no messages are printed through logboek. - this loop is not interruptable by the signal watcher in tomb package. Deprecated: use NewSilentLoopWithParams in futures versions NewSilentLoop will take Params
func NewSilentLoopWithParams ¶
func NewSilentLoopWithParamsOpts ¶
func NewSilentLoopWithParamsOpts(opts ...ParamsBuilderOpt) *Loop
func (*Loop) BreakIf ¶
func (l *Loop) BreakIf(pred BreakPredicate) *Loop
func (*Loop) RunContext ¶
RunContext retries a task like Run but breaks if context done.
func (*Loop) WithInterruptable ¶
func (*Loop) WithShowError ¶
type Params ¶
type Params interface {
WithName(n string) Params
WithAttempts(attempts int) Params
WithWait(wait time.Duration) Params
WithLogger(logger log.Logger) Params
Name() string
Attempts() int
Wait() time.Duration
Logger() log.Logger
Clone() Params
Fill(c Params) Params
}
func NewEmptyParams ¶
func NewEmptyParams(opts ...ParamsBuilderOpt) Params
func SafeCloneOrNewParams ¶
func SafeCloneOrNewParams(p Params, opts ...ParamsBuilderOpt) Params
type ParamsBuilderOpt ¶
type ParamsBuilderOpt func(Params)
func AttemptsWithWaitOpts ¶
func AttemptsWithWaitOpts(attempts int, wait time.Duration) []ParamsBuilderOpt
func WithAttempts ¶
func WithAttempts(attempts int) ParamsBuilderOpt
func WithLogger ¶
func WithLogger(logger log.Logger) ParamsBuilderOpt
func WithName ¶
func WithName(name string) ParamsBuilderOpt
func WithWait ¶
func WithWait(wait time.Duration) ParamsBuilderOpt