runner

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrencyProvider

type ConcurrencyProvider interface {
	Acquire() int
	Release(ticket int)
	Schedule(action func())
	Close()
}

func NewSharedProvider

func NewSharedProvider(maxConcurrency int) ConcurrencyProvider

type RunnerConfig

type RunnerConfig struct {
	MaxConcurrency int
}

type RunnerStatus

type RunnerStatus int

A RunnerStatus represents the status of a runner.

const (
	// RunnerIdle indicates that the runner is idle i.e. not running any tasks.
	RunnerIdle RunnerStatus = iota
	// RunnerRunning indicates that the runner is currently running pre tasks.
	RunnerPreparing
	// RunnerRunning indicates that the runner is currently running main tasks.
	RunnerRunning
	// RunnerRunning indicates that the runner is currently running post tasks.
	RunnerShuttingDown
	// RunnerCanceled indicates that the runner has been canceled.
	RunnerCanceled
	// RunnerErrored indicates that the runner has encountered an error.
	RunnerErrored
)

type RunnerUpdate

type RunnerUpdate struct {
	// Status is the status of the runner.
	Status RunnerStatus
	// UpdatedNode is the status of the current node.
	UpdatedNode *TreeStatusNode
	// StatusRoot is the root node of the task tree.
	StatusRoot *TreeStatusNode
}

A RunnerUpdate represents an update of the runner status.

type Scheduler

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

func NewScheduler

func NewScheduler() *Scheduler

func (*Scheduler) Cancel

func (s *Scheduler) Cancel() error

func (*Scheduler) CancelTask

func (s *Scheduler) CancelTask(name string)

func (*Scheduler) Schedule

func (s *Scheduler) Schedule(task tasks.Task)

func (*Scheduler) Status

func (s *Scheduler) Status() SchedulerStatus

func (*Scheduler) Updates

func (s *Scheduler) Updates() <-chan SchedulerStatus

type SchedulerStatus

type SchedulerStatus = map[string]TaskStatus

type SharedConcurrencyProvider

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

func (*SharedConcurrencyProvider) Acquire

func (c *SharedConcurrencyProvider) Acquire() int

func (*SharedConcurrencyProvider) Close

func (c *SharedConcurrencyProvider) Close()

func (*SharedConcurrencyProvider) Release

func (c *SharedConcurrencyProvider) Release(ticket int)

func (*SharedConcurrencyProvider) Schedule

func (c *SharedConcurrencyProvider) Schedule(action func())

type TaskRunner

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

func NewListRunner

func NewListRunner(name string, tasks []tasks.Task, maxConcurrency int) *TaskRunner

func NewParallelRunner

func NewParallelRunner(name string, tasks []tasks.Task, maxConcurrency int) *TaskRunner

func NewSequentialRunner

func NewSequentialRunner(name string, tasks []tasks.Task) *TaskRunner

func (*TaskRunner) Cancel

func (tr *TaskRunner) Cancel() error

func (*TaskRunner) Name

func (tr *TaskRunner) Name() string

func (*TaskRunner) Run

func (tr *TaskRunner) Run() error

func (*TaskRunner) Status

func (tr *TaskRunner) Status() TaskRunnerStatus

func (*TaskRunner) Updates

func (tr *TaskRunner) Updates() <-chan TaskRunnerStatus

type TaskRunnerStatus

type TaskRunnerStatus = map[string]TaskStatus

type TaskStatus

type TaskStatus int

A TaskStatus represents the status of a task.

const (
	// StatusPending indicates that the task is pending.
	StatusPending TaskStatus = iota
	// StatusScheduled indicates that the task is scheduled for execution.
	StatusScheduled
	// StatusRunning indicates that the task is currently running.
	StatusRunning
	// StatusDone indicates that the task has been successfully executed.
	StatusDone
	// StatusError indicates that the task has failed.
	StatusError
	// StatusCanceled indicates that the task has been canceled.
	StatusCanceled
)

type TaskTreeRunner

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

A TaskTreeRunner represents a runner for a task tree.

func (*TaskTreeRunner) Cancel

func (r *TaskTreeRunner) Cancel()

func (*TaskTreeRunner) ShutdownGracefully

func (r *TaskTreeRunner) ShutdownGracefully()

ShutdownGracefully cancels only long running tasks transitioning those trees into the $post subtree

func (*TaskTreeRunner) Start

func (r *TaskTreeRunner) Start() error

func (*TaskTreeRunner) Status

func (r *TaskTreeRunner) Status() *TreeStatusNode

func (*TaskTreeRunner) Updates

func (r *TaskTreeRunner) Updates() <-chan *TreeStatusNode

type TreeStatusNode

type TreeStatusNode struct {
	// ID is a unique identifier of the original node.
	ID string
	// Name is the name of the node.
	Name string
	// AggregatedStatus is the status of the node.
	AggregatedStatus TaskStatus
	// MainName is the name of the main task
	MainName string
	// Status is the status of the main task
	Status TaskStatus
	// PreNodes is a collection of nodes that should be executed before the main task.
	PreNodes []*TreeStatusNode
	// PostNodes is a collection of nodes that should be executed after the main task.
	PostNodes []*TreeStatusNode
	// Parent is the parent node.
	Parent *TreeStatusNode
	// Error is the error that occurred during the execution of the main task.
	Error error
}

A TreeStatusNode represents the status of a task tree node. The status of a task tree is represented in a tree structure od TreeStatusNodes that mirrors the task tree.

func (*TreeStatusNode) GetDirectChildren

func (t *TreeStatusNode) GetDirectChildren() []*TreeStatusNode

func (*TreeStatusNode) IsDone

func (t *TreeStatusNode) IsDone() bool

func (*TreeStatusNode) IsPost

func (t *TreeStatusNode) IsPost() bool

func (*TreeStatusNode) IsPre

func (t *TreeStatusNode) IsPre() bool

func (*TreeStatusNode) Iterate

func (t *TreeStatusNode) Iterate(handler func(node *TreeStatusNode))

func (*TreeStatusNode) Update

func (t *TreeStatusNode) Update()

Jump to

Keyboard shortcuts

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