tasks

package
v0.0.0-...-11bfd58 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package tasks provides helpers for managing scheduled tasks.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTaskNotFound indicates a failure due to task resolution
	ErrTaskNotFound = errors.New("task not found")
	// ErrNotRegistered indicates that the querired Scheduled Task
	// is not registered in the Windows Task Scheduler
	ErrNotRegistered = errors.New("scheduled task is not registered")
)

Functions

func Create

func Create(id, path, args, name, user string, trigger taskmaster.Trigger) error

Create attempts to create a scheduled task.

Set common defaults for name and user to reduce the amount of required args.

Example taskmaster.Trigger that creates a new task on startup with a two minute delay:

taskmaster.BootTrigger{
  TaskTrigger: taskmaster.TaskTrigger{
		 Enabled: true,
		 ID:      "startup",
	 },
	 Delay: period.NewHMS(0, 2, 0),
},

func Delete

func Delete(name string) error

Delete attempts to delete a scheduled task.

func Disable

func Disable(name string) error

Disable disables a scheduled task.

func Enable

func Enable(name string) error

Enable enables a scheduled task.

func Start

func Start(name string) error

Start attempts to start a scheduled task. This helper does not follow the running task or wait for execution to complete.

func TaskExists

func TaskExists(name string) (bool, error)

TaskExists is a helper function that detects whether a scheduled task exists.

Types

type TaskInfo

type TaskInfo struct {
	Name           string
	State          taskmaster.TaskState
	LastTaskResult taskmaster.TaskResult
	NextRunTime    time.Time
	LastRunTime    time.Time
}

TaskInfo describes a registered task using data from taskmaster.RegisteredTask.

func Fetch

func Fetch(name string) (TaskInfo, error)

Fetch fetches a scheduled tasks state.

Jump to

Keyboard shortcuts

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