task

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OnSuccess

func OnSuccess(f func() error, g func() error) func() error

func Run

func Run(ctx context.Context, tasks ...func() error) error

Types

type Periodic

type Periodic struct {
	// Interval of the task being run
	Interval time.Duration
	// Execute is the task function
	Execute func() error
	// contains filtered or unexported fields
}

Periodic is a task that runs periodically.

func (*Periodic) Close

func (t *Periodic) Close() error

Close implements common.Closable.

func (*Periodic) Start

func (t *Periodic) Start() error

Start implements common.Runnable.

type PeriodicTask

type PeriodicTask struct {
	Interval time.Duration // How often to run the task
	// contains filtered or unexported fields
}

PeriodicTask is a struct that periodically runs a specified task

func NewPeriodicTask

func NewPeriodicTask(interval time.Duration, task func() error, opts ...PeriodicTaskOption) *PeriodicTask

NewPeriodicTask creates a new PeriodicTask with the given interval and task

func (*PeriodicTask) Close

func (pt *PeriodicTask) Close() error

Close stops the periodic task and waits for it to finish

func (*PeriodicTask) ResetInterval

func (pt *PeriodicTask) ResetInterval(interval time.Duration)

func (*PeriodicTask) Start

func (pt *PeriodicTask) Start() error

Start begins running the task periodically does not block

type PeriodicTaskOption

type PeriodicTaskOption func(*PeriodicTask)

func WithStartImmediately

func WithStartImmediately() PeriodicTaskOption

Jump to

Keyboard shortcuts

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