package tasks

import "github.com/gohugoio/hugo/common/tasks"

Index

Types

type Func

type Func struct {
	// The shortest interval between each run.
	IntervalLow time.Duration

	// The longest interval between each run.
	IntervalHigh time.Duration

	// The function to run.
	F func(interval time.Duration) (time.Duration, error)
	// contains filtered or unexported fields
}

type RunEvery

type RunEvery struct {
	// Any error returned from the function will be passed to this function.
	HandleError func(string, error)

	// If set, the function will be run immediately.
	RunImmediately bool
	// contains filtered or unexported fields
}

RunEvery runs a function at intervals defined by the function itself. Functions can be added and removed while running.

func (*RunEvery) Add

func (r *RunEvery) Add(name string, f Func)

Add adds a function to the RunEvery.

func (*RunEvery) Close

func (r *RunEvery) Close() error

Close stops the RunEvery from running.

func (*RunEvery) Has

func (r *RunEvery) Has(name string) bool

Has returns whether the RunEvery has a function with the given name.

func (*RunEvery) Remove

func (r *RunEvery) Remove(name string)

Remove removes a function from the RunEvery.

func (*RunEvery) Start

func (r *RunEvery) Start() error

Source Files

tasks.go

Version
v0.144.2 (latest)
Published
Feb 19, 2025
Platform
linux/amd64
Imports
2 packages
Last checked
13 hours ago

Tools for package owners.