cron

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Overview

Package cron contains functionality for executing code in a recurring fashion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JobFunc

type JobFunc func(ctx context.Context) (int, error)

JobFunc contains the payload function that will be run from Task. The int return value may or may not reflect on any error situations.

type Task

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

Task allows executing functions in recurring points in time, depending on the system time. Considering container restarts or pod kills, this behavior is more flexible than a regular time ticker.

func New

func New(ctx context.Context, expr string, jobClosure JobFunc) (*Task, error)

New creates a new instance for executing the same task. The task must be provided to its Run() function.

func (*Task) Run

func (t *Task) Run()

Run executes the given function. It can be stopped with Stop(). Please note that Run() does not return an error.

func (*Task) Running added in v0.0.2

func (t *Task) Running() bool

Running checks whether the taskRunner is running.

func (*Task) Stop

func (t *Task) Stop()

Stop stops the looping over the provided function given to Run().

Jump to

Keyboard shortcuts

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