task

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JobsAllocator added in v0.4.6

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

func NewConstantJobsAllocator added in v0.4.6

func NewConstantJobsAllocator(num int) *JobsAllocator

func (*JobsAllocator) AvailableJobs added in v0.4.6

func (allocator *JobsAllocator) AvailableJobs(tracker *Task) int

func (*JobsAllocator) Init added in v0.4.6

func (allocator *JobsAllocator) Init()

Init jobs allocation. This method is used to request allocation of jobs for the first time.

func (*JobsAllocator) MaxJobs added in v0.4.6

func (allocator *JobsAllocator) MaxJobs() int

type JobsScheduler added in v0.4.6

type JobsScheduler struct {
	*sync.Cond
	// contains filtered or unexported fields
}

JobsScheduler allocates jobs to multiple tasks.

func NewJobsScheduler added in v0.4.6

func NewJobsScheduler(num int) *JobsScheduler

NewJobsScheduler creates a JobsScheduler with num jobs.

func (*JobsScheduler) GetJobsAllocator added in v0.4.6

func (s *JobsScheduler) GetJobsAllocator(taskName string) *JobsAllocator

func (*JobsScheduler) Register added in v0.4.6

func (s *JobsScheduler) Register(taskName string, priority int, privileged bool) bool

Register a task in the JobsScheduler. Registered tasks will be ignored and return false.

func (*JobsScheduler) Unregister added in v0.4.6

func (s *JobsScheduler) Unregister(taskName string)

Unregister a task from the JobsScheduler.

type Monitor

type Monitor struct {
	TaskLock sync.Mutex
	Tasks    map[string]*Task
}

Monitor monitors the progress of all tasks.

func NewTaskMonitor

func NewTaskMonitor() *Monitor

NewTaskMonitor creates a Monitor and add pending tasks.

func (*Monitor) Add

func (tm *Monitor) Add(name string, done int)

Add the progress of a task.

func (*Monitor) Fail

func (tm *Monitor) Fail(name, err string)

func (*Monitor) Finish

func (tm *Monitor) Finish(name string)

Finish a task.

func (*Monitor) Get

func (tm *Monitor) Get(name string) int

Get the progress of a task.

func (*Monitor) GetTask

func (tm *Monitor) GetTask(name string) *Task

func (*Monitor) List

func (tm *Monitor) List(workers ...string) []Task

List all tasks and remove tasks from disconnected workers.

func (*Monitor) Pending

func (tm *Monitor) Pending(name string)

Pending a task.

func (*Monitor) Start

func (tm *Monitor) Start(name string, total int) *Task

Start a task.

func (*Monitor) Suspend

func (tm *Monitor) Suspend(name string, flag bool)

Suspend a task.

func (*Monitor) Update

func (tm *Monitor) Update(name string, done int)

Update the progress of a task.

type Status

type Status string
const (
	StatusPending   Status = "Pending"
	StatusComplete  Status = "Complete"
	StatusRunning   Status = "Running"
	StatusSuspended Status = "Suspended"
	StatusFailed    Status = "Failed"
)

type SubTask

type SubTask struct {
	Start  int
	End    int
	Parent *Task
}

func (*SubTask) Add

func (t *SubTask) Add(done int)

func (*SubTask) Finish

func (t *SubTask) Finish()

type Task

type Task struct {
	Name       string
	Status     Status
	Done       int
	Total      int
	StartTime  time.Time
	FinishTime time.Time
	Error      string
}

Task progress information.

func NewTask

func NewTask(name string, total int) *Task

func (*Task) Add

func (t *Task) Add(done int)

func (*Task) Fail

func (t *Task) Fail(err string)

func (*Task) Finish

func (t *Task) Finish()

func (*Task) SubTask

func (t *Task) SubTask(done int) *SubTask

func (*Task) Suspend

func (t *Task) Suspend(flag bool)

func (*Task) Update

func (t *Task) Update(done int)

type Tasks

type Tasks []Task

Tasks is used to sort []Task.

func (Tasks) Len

func (t Tasks) Len() int

Len is used to sort []Task.

func (Tasks) Less

func (t Tasks) Less(i, j int) bool

Less is used to sort []Task.

func (Tasks) Swap

func (t Tasks) Swap(i, j int)

Swap is used to sort []Task.

Jump to

Keyboard shortcuts

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