taskrun

package
v1.3.0-rc.0...-d217119 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Elem

type Elem struct {
	TimeoutCh <-chan struct{}
	Cancel    context.CancelFunc
	Timeout   time.Duration

	ErrCh  chan error
	DoneCh chan interface{}

	ExitCh chan struct{}
}

type Op

type Op string

Op represents task operation.

const (
	Prepare Op = "prepare"
	Create  Op = "create"
	Start   Op = "start"
	Queue   Op = "queue"
	Wait    Op = "wait"
)

type TaskOp

type TaskOp interface {
	Op() Op

	TaskRun() *TaskRun

	// Processing represents what the `op` really do, you shouldn't update task inside `processing`.
	// you should put update logic in `WhenXXX`.
	Processing() (interface{}, error)

	// WhenDone will be invoked if task op is done.
	WhenDone(data interface{}) error

	// WhenLogicError will be invoked if task occurred an error when do logic.
	WhenLogicError(err error) error

	// WhenTimeout will be invoked if task is timeout.
	WhenTimeout() error

	// WhenCancel will be invoked if task is canceled.
	WhenCancel() error

	TimeoutConfig() (<-chan struct{}, context.CancelFunc, time.Duration)

	// TuneTriggers return corresponding triggers at concrete tune point.
	TuneTriggers() TaskOpTuneTriggers
}

type TaskOpTuneTriggers

type TaskOpTuneTriggers struct {
	BeforeProcessing aoptypes.TuneTrigger
	AfterProcessing  aoptypes.TuneTrigger
}

type TaskRun

type TaskRun struct {
	Task *spec.PipelineTask

	Ctx      context.Context
	Executor types.ActionExecutor
	P        *spec.Pipeline

	ClusterInfo  clusterinfo.Interface
	EdgeRegister edgepipeline_register.Interface
	Bdl          *bundle.Bundle
	DBClient     *dbclient.Client

	QuitQueueTimeout bool
	QuitWaitTimeout  bool

	StopQueueLoop bool
	StopWaitLoop  bool

	ExecutorDoneCh chan spec.ExecutorDoneChanData

	// 轮训状态间隔期间可能任务已经是终态,FakeTimeout = true
	FakeTimeout bool

	// svc
	ActionAgentSvc actionagent.Interface
	ActionMgr      actionmgr.Interface

	RetryInterval time.Duration
}

TaskRun represents task runtime.

func New

func New(ctx context.Context, task *spec.PipelineTask,
	executor types.ActionExecutor, p *spec.Pipeline, bdl *bundle.Bundle, dbClient *dbclient.Client,
	actionAgentSvc actionagent.Interface,
	actionMgr actionmgr.Interface, clusterInfo clusterinfo.Interface, edgeRegister edgepipeline_register.Interface,
	retryInterval time.Duration,
) *TaskRun

New returns a TaskRun. TODO refactored into task reconciler.

func (*TaskRun) AppendLastMsg

func (tr *TaskRun) AppendLastMsg(msg string) error

func (*TaskRun) Do

func (tr *TaskRun) Do(itr TaskOp) error

func (*TaskRun) LogStep

func (tr *TaskRun) LogStep(taskOp Op, step string)

reconciler: pipelineID: 1, taskID: 1, taskName: repo, taskOp: start, step: begin do WhenDone

func (*TaskRun) Teardown

func (tr *TaskRun) Teardown()

Teardown tear down task.

func (*TaskRun) Update

func (tr *TaskRun) Update()

Update must update without error

func (*TaskRun) UpdateTaskInspect

func (tr *TaskRun) UpdateTaskInspect(inspect string) error

UpdateTaskInspect update task inspect, and get events from inspect

func (*TaskRun) WhenCancel

func (tr *TaskRun) WhenCancel() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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