tasks

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: GPL-3.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecWithInterval added in v0.0.4

func ExecWithInterval(fn StoppableFunc, start, limit time.Duration)

ExecWithInterval executes a function with a dynamic interval the interval is getting multiplied by 2 in each round, up to the given limit and then it starts all over 1s > 2s > 4s > 8s ... > 1s > 2s > ...

func ExecWithTimeout

func ExecWithTimeout(ctx context.Context, logger *zap.Logger, fn Func, t time.Duration) (bool, interface{}, error)

ExecWithTimeout triggers some function in the given time frame, returns true if completed

func NewExecutionQueue added in v0.0.19

func NewExecutionQueue(interval time.Duration, opt ...ExecQueueOpt) queue.Queue

NewExecutionQueue creates a new instance

func Retry added in v0.0.19

func Retry(fn Fn, retries int) error

Retry executes a function x times or until successful

func RetryWithContext added in v0.1.5

func RetryWithContext(pctx context.Context, fn Fn, retries int) error

RetryWithContext executes a function x times or until successful

Types

type ExecQueueOpt added in v0.2.0

type ExecQueueOpt func(*executionQueue)

ExecQueueOpt enables to inject more parameters

func WithoutErrors added in v0.2.0

func WithoutErrors() ExecQueueOpt

WithoutErrors disables errors

type Fn added in v0.0.18

type Fn = queue.Fn

Fn represents a function to execute

type Func

type Func = func(stopper Stopper) (interface{}, error)

Func is the interface of functions to trigger

type StoppableFunc added in v0.0.4

type StoppableFunc func(lastTick time.Duration) (stop bool, cont bool)

StoppableFunc represents a function that returns two boolean to help with its execution stop will stop the interval, while continue will make the interval value to remain the same if both are false, the interval will be increased (x2)

type Stopper added in v0.0.4

type Stopper interface {
	// IsStopped returns true if the stopper already stopped
	IsStopped() bool
}

Stopper represents the object used to stop running functions should be used by the running function, once stopped the function act accordingly

Jump to

Keyboard shortcuts

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