types

package
v0.0.0-...-446b646 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exec

type Exec struct {
	TaskDone  int
	TaskTotal int
	// contains filtered or unexported fields
}

func NewExec

func NewExec(name string, fn func(io.Writer, *Exec) error) *Exec

func NewExecWithContext

func NewExecWithContext(name string, fn func(context.Context, io.Writer, *Exec) error) *Exec

func (*Exec) Cancel

func (e *Exec) Cancel()

func (*Exec) Description

func (e *Exec) Description() string

func (*Exec) Err

func (e *Exec) Err() error

func (*Exec) Log

func (e *Exec) Log() string

func (*Exec) Progress

func (e *Exec) Progress() (int, int)

func (*Exec) Run

func (e *Exec) Run()

func (*Exec) Status

func (e *Exec) Status() Status

type Mgr

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

func NewMgr

func NewMgr() *Mgr

func (*Mgr) Add

func (m *Mgr) Add(task Task)

func (*Mgr) Cancel

func (m *Mgr) Cancel(id uint64)

func (*Mgr) Clear

func (m *Mgr) Clear()

func (*Mgr) List

func (m *Mgr) List() []TaskDetail

type Status

type Status int
const (
	PENDING Status = iota
	RUNNING
	CANCELLED
	DONE
	ERROR
)

func (Status) Str

func (s Status) Str() string

type Task

type Task interface {
	Description() string
	Run()
	Cancel()
	Status() Status
	Progress() (int, int)
	Log() string
	Err() error
}

type TaskDetail

type TaskDetail struct {
	Id        uint64    `json:"id"`
	Added     time.Time `json:"added"`
	Name      string    `json:"name"`
	StatusStr string    `json:"status"`
	Log       string    `json:"log,omitempty"`
	ErrStr    string    `json:"err,omitempty"`
	TaskDone  int       `json:"task_done"`
	TaskTotal int       `json:"task_total"`
}

Jump to

Keyboard shortcuts

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