loop

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loop

type Loop struct {
	// contains filtered or unexported fields
}

func NewLoop

func NewLoop() *Loop

func (*Loop) Do

func (l *Loop) Do(tf TaskFunc, opts ...TaskOptions)

func (*Loop) DoAndWait

func (l *Loop) DoAndWait(tf TaskFunc, opts ...TaskOptions) (interface{}, error)

func (*Loop) Repeat

func (l *Loop) Repeat(tf TaskFunc, opts ...TaskOptions)

func (*Loop) Run

type RepeatIntervalFunc

type RepeatIntervalFunc func(result interface{}, err error) time.Duration

RepeatIntervalFunc is used when schedule repeated TaskFunc. it takes result and error of previous TaskFunc invocation and determine the delay of next TaskFunc invocation

type TaskFunc

type TaskFunc func(ctx context.Context, l *Loop) (ret interface{}, err error)

TaskFunc can be scheduled to Loop with TaskOptions

type TaskOption

type TaskOption struct {
	RepeatIntervalFunc RepeatIntervalFunc
}

type TaskOptions

type TaskOptions func(opt *TaskOption)

func ExponentialRepeatIntervalOnError

func ExponentialRepeatIntervalOnError(init time.Duration, factor float64) TaskOptions

ExponentialRepeatIntervalOnError returns a TaskOptions which set repeat interval to be exponentially increased if error is not nil. the repeat interval is reset to "init" if error is nil

func FixedRepeatInterval

func FixedRepeatInterval(interval time.Duration) TaskOptions

FixedRepeatInterval returns a TaskOptions which set repeat interval to be fixed duration

Jump to

Keyboard shortcuts

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