task

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a process is not found.
	ErrNotFound = errors.New("task not found")

	// ErrAlreadyStarted is returned when a process is already started.
	ErrAlreadyStarted = errors.New("task already started")
)

Functions

This section is empty.

Types

type Manager

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

Manager manages tasks.

func NewManager

func NewManager(ctx context.Context) *Manager

NewManager returns a new task manager.

func (*Manager) Add

func (m *Manager) Add(id string, fn func(context.Context) error)

Add adds a task to the manager. If the process already exists, it is a no-op.

func (*Manager) Exists

func (m *Manager) Exists(id string) bool

Exists checks if a task exists.

func (*Manager) Run

func (m *Manager) Run(id string, done chan<- error)

Run starts the task if it exists. Otherwise, it waits for the process to finish.

func (*Manager) Stop

func (m *Manager) Stop(id string) error

Stop stops the task and removes it from the manager.

type Task

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

Task is a task that can be started and stopped.

Jump to

Keyboard shortcuts

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