task

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Task

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

Task runs a function at fixed duration.

func New added in v0.4.6

func New(fn func(ctx context.Context)) *Task

New returns a new task for use. fn is main function which will called in task loop. By default, its duration is 1min, and you can change it by Duration().

func (*Task) After

func (t *Task) After(fn func(ctx context.Context)) *Task

After sets fn to task which will be called after task stopping.

func (*Task) Before

func (t *Task) Before(fn func(ctx context.Context)) *Task

Before sets fn to task which will be called before task starting.

func (*Task) Context added in v0.4.6

func (t *Task) Context(ctx context.Context) *Task

Context sets ctx to task which will be passed to its functions in order to control context.

func (*Task) Duration added in v0.4.6

func (t *Task) Duration(duration time.Duration) *Task

Duration sets duration to task which controls the duration between two task loops.

func (*Task) Run

func (t *Task) Run()

Run runs task. You can use context to stop this task, see context.Context.

Jump to

Keyboard shortcuts

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