Help us shape the future of Go! Take the 2026 Go Developer Survey

task

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const AllLocalReposResourcesKey = "__alllocalrepos__"

AllLocalReposResourcesKey to be used as resource key when all local repos are needed

View Source
const AllResourcesKey = "__all__"

AllResourcesKey to be used as resource key when all resources are needed

Variables

This section is empty.

Functions

This section is empty.

Types

type Detail

type Detail struct {
	atomic.Value
}

Detail represents custom task details

type List

type List struct {
	*sync.Mutex
	// contains filtered or unexported fields
}

List is handling list of processes and makes sure only one process is executed at the time

func NewList

func NewList() *List

NewList creates empty task list

func (*List) Clear

func (list *List) Clear()

Clear removes finished tasks from list

func (*List) DeleteTaskByID

func (list *List) DeleteTaskByID(ID int) (Task, error)

DeleteTaskByID deletes given task from list. Only finished tasks can be deleted.

func (*List) GetTaskByID

func (list *List) GetTaskByID(ID int) (Task, error)

GetTaskByID returns task with given id

func (*List) GetTaskDetailByID

func (list *List) GetTaskDetailByID(ID int) (interface{}, error)

GetTaskDetailByID returns detail of task with given id

func (*List) GetTaskErrorByID added in v1.6.0

func (list *List) GetTaskErrorByID(ID int) (error, error)

GetTaskErrorByID returns the Task error for a given id

func (*List) GetTaskOutputByID

func (list *List) GetTaskOutputByID(ID int) (string, error)

GetTaskOutputByID returns standard output of task with given id

func (*List) GetTaskReturnValueByID

func (list *List) GetTaskReturnValueByID(ID int) (*ProcessReturnValue, error)

GetTaskReturnValueByID returns process return value of task with given id

func (*List) GetTasks

func (list *List) GetTasks() []Task

GetTasks gets complete list of tasks

func (*List) RunTaskInBackground

func (list *List) RunTaskInBackground(name string, resources []string, process Process) (Task, *ResourceConflictError)

RunTaskInBackground creates task and runs it in background. This will block until the necessary resources become available.

func (*List) Stop added in v1.6.0

func (list *List) Stop()

Stop signals the consumer to stop processing tasks and waits for it to finish

func (*List) Wait

func (list *List) Wait()

Wait waits till all tasks are processed

func (*List) WaitForTaskByID

func (list *List) WaitForTaskByID(ID int) (Task, error)

WaitForTaskByID waits for task with given id to be processed

type Output

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

Output represents a safe standard output of task which is compatbile to AptlyProgress.

func NewOutput

func NewOutput() *Output

NewOutput creates new output

func (*Output) AddBar

func (t *Output) AddBar(_ int)

AddBar is needed for progress compatibility

func (*Output) ColoredPrintf

func (t *Output) ColoredPrintf(msg string, a ...interface{})

ColoredPrintf does printf in a safe manner + newline currently are no colors supported.

func (*Output) Flush

func (t *Output) Flush()

Flush is needed for progress compatibility

func (*Output) InitBar

func (t *Output) InitBar(_ int64, _ bool, _ aptly.BarType)

InitBar is needed for progress compatibility

func (*Output) Print

func (t *Output) Print(msg string)

Print does printf in a safe manner

func (*Output) Printf

func (t *Output) Printf(msg string, a ...interface{})

Printf does printf in a safe manner

func (*Output) PrintfStdErr

func (t *Output) PrintfStdErr(msg string, a ...interface{})

PrintfStdErr does printf but in safe manner to output

func (*Output) SetBar

func (t *Output) SetBar(_ int)

SetBar sets current position for progress bar

func (*Output) Shutdown

func (t *Output) Shutdown()

Shutdown is needed for progress compatibility

func (*Output) ShutdownBar

func (t *Output) ShutdownBar()

ShutdownBar is needed for progress compatibility

func (*Output) Start

func (t *Output) Start()

Start is needed for progress compatibility

func (*Output) String

func (t *Output) String() string

func (*Output) Write

func (t *Output) Write(p []byte) (n int, err error)

Write is used to determine how many bytes have been written not needed in our case.

func (*Output) WriteString

func (t *Output) WriteString(s string) (n int, err error)

WriteString writes string to output

type Process

type Process func(out aptly.Progress, detail *Detail) (*ProcessReturnValue, error)

Process is a function implementing the actual task logic

type ProcessReturnValue

type ProcessReturnValue struct {
	Code  int
	Value interface{}
}

type PublishDetail

type PublishDetail struct {
	*Detail
	TotalNumberOfPackages     int64
	RemainingNumberOfPackages int64
}

PublishDetail represents publish task details

type PublishOutput

type PublishOutput struct {
	aptly.Progress
	PublishDetail
	// contains filtered or unexported fields
}

PublishOutput specific output for publishing api

func (*PublishOutput) AddBar

func (t *PublishOutput) AddBar(_ int)

AddBar publish output specific

func (*PublishOutput) InitBar

func (t *PublishOutput) InitBar(count int64, _ bool, barType aptly.BarType)

InitBar publish output specific

func (*PublishOutput) ShutdownBar

func (t *PublishOutput) ShutdownBar()

ShutdownBar publish output specific

type ResourceConflictError

type ResourceConflictError struct {
	Tasks   []Task
	Message string
}

ResourceConflictError represents a list tasks using conflicitng resources

func (*ResourceConflictError) Error

func (e *ResourceConflictError) Error() string

type ResourcesSet

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

ResourcesSet represents a set of task resources. A resource is represented by its unique key

func NewResourcesSet

func NewResourcesSet() *ResourcesSet

NewResourcesSet creates new instance of resources set

func (*ResourcesSet) Free

func (r *ResourcesSet) Free(resources []string)

Free removes given resources from dependency set

func (*ResourcesSet) MarkInUse

func (r *ResourcesSet) MarkInUse(resources []string, task *Task)

MarkInUse given resources as used by given task

func (*ResourcesSet) UsedBy

func (r *ResourcesSet) UsedBy(resources []string) []Task

UsedBy checks whether one of given resources is used by a task and if yes returns slice of such task

type State

type State int

State task is in

const (
	// IDLE when task is waiting
	IDLE State = iota
	// RUNNING when task is running
	RUNNING
	// SUCCEEDED when task is successfully finished
	SUCCEEDED
	// FAILED when task failed
	FAILED
)

type Task

type Task struct {
	Name      string
	ID        int
	State     State
	Resources []string
	// contains filtered or unexported fields
}

Task represents as task in a queue encapsulates process code All fields are protected by List.Mutex - access task fields only while holding list.Lock()

func NewTask

func NewTask(process Process, name string, ID int, resources []string, wgTask *sync.WaitGroup) *Task

NewTask creates new task

Jump to

Keyboard shortcuts

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