taskengine

package
v0.0.0-...-028f1de Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NormalTaskType  = 0
	SessionTaskType = 1
)
View Source
const (
	ESuccess            = 0
	EFileCreateFail     = 1
	EChownError         = 2
	EChmodError         = 3
	ECreateDirFailed    = 4
	EInvalidFilePath    = 10
	EFileAlreadyExist   = 11
	EEmptyContent       = 12
	EInvalidContent     = 13
	EInvalidContentType = 14
	EInvalidFileType    = 15
	EInvalidSignature   = 16
	EInalidFileMode     = 17
	EInalidGID          = 18
	EInalidUID          = 19
)
View Source
const (
	ErrUpdatingProcedureRunning = -7
)

Variables

View Source
var (
	// FetchingTaskLock indicates whether one goroutine is fetching tasks
	FetchingTaskLock heavylock.CASMutex
	// FetchingTaskCounter indicates how many goroutines are fetching tasks
	FetchingTaskCounter atomicutil.AtomicInt32
)
View Source
var G_IsFreebsd bool = false
View Source
var G_IsLinux bool = false
View Source
var G_IsWindows bool = false

Functions

func DoSessionTask

func DoSessionTask(tasks []models.SessionTaskInfo)

func EnableFetchingTask

func EnableFetchingTask()

EnableFetchingTask sets prviate indicator to allow fetching tasks

func Fetch

func Fetch(from_kick bool, taskId string, taskType int) int

func FetchTaskList

func FetchTaskList(reason FetchReason, taskId string, taskType int, isColdstart bool) *taskCollection

func GetPool

func GetPool() *taskPool

func GetPrecheckPool

func GetPrecheckPool() *taskPool

func IsStartupFetched

func IsStartupFetched() bool

func ReportSessionResult

func ReportSessionResult(taskID string, status string)

func SendFileFinished

func SendFileFinished(sendFile models.SendFileTaskInfo, status int)

func SendFileInvalid

func SendFileInvalid(sendFile models.SendFileTaskInfo, status int)

func SendFiles

func SendFiles(sendFileTasks []models.SendFileTaskInfo)

Types

type FetchReason

type FetchReason string
const (
	FetchOnKickoff FetchReason = "kickoff"
	FetchOnStartup FetchReason = "startup"
)

type FinishCallback

type FinishCallback func()

type PeriodicTaskSchedule

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

PeriodicTaskSchedule consists of timer and reusable invocation data structure for periodic task

type SessionFactory

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

func GetSessionFactory

func GetSessionFactory() *SessionFactory

func (*SessionFactory) AddSessionTask

func (t *SessionFactory) AddSessionTask(task *SessionTask)

func (*SessionFactory) ContainsTask

func (t *SessionFactory) ContainsTask(name string) bool

func (*SessionFactory) GetTask

func (t *SessionFactory) GetTask(name string) (*SessionTask, bool)

func (*SessionFactory) IsAnyTaskRunning

func (t *SessionFactory) IsAnyTaskRunning() bool

func (*SessionFactory) RemoveTask

func (t *SessionFactory) RemoveTask(name string)

type SessionTask

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

func NewSessionTask

func NewSessionTask(sessionId string, websocketUrl string, taskId string,
	cmdContent string, username string, passwordName string, targetHost string,
	portNumber string, flowLimit int) *SessionTask

func (*SessionTask) RunTask

func (sessionTask *SessionTask) RunTask(taskid string) error

func (*SessionTask) StopTask

func (sessionTask *SessionTask) StopTask() error

type Task

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

func NewTask

func NewTask(taskInfo models.RunTaskInfo, scheduleLocation *time.Location, onFinish FinishCallback) *Task

func (*Task) Cancel

func (task *Task) Cancel(quietly bool)

Cancel the task invocation. If quietly is false, notify server the task is canceled.

func (*Task) IsCancled

func (task *Task) IsCancled() bool

func (*Task) PreCheck

func (task *Task) PreCheck(reportVerified bool) error

func (*Task) Run

func (task *Task) Run() (taskerrors.ErrorCode, error)

func (*Task) SendError

func (task *Task) SendError(output string, errCode fmt.Stringer, errDesc string)

func (*Task) SendInvalidTask

func (task *Task) SendInvalidTask(param string, value string)

type TaskFactory

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

func GetTaskFactory

func GetTaskFactory() *TaskFactory

func (*TaskFactory) AddNamedTask

func (t *TaskFactory) AddNamedTask(name string, task *Task) error

func (*TaskFactory) AddTask

func (t *TaskFactory) AddTask(task *Task) error

func (*TaskFactory) ContainsTaskByName

func (t *TaskFactory) ContainsTaskByName(name string) bool

func (*TaskFactory) GetTask

func (t *TaskFactory) GetTask(name string) (*Task, bool)

func (*TaskFactory) IsAnyNonPeriodicTaskRunning

func (t *TaskFactory) IsAnyNonPeriodicTaskRunning() bool

IsAnyNonPeriodicTaskRunning scans each task registered in TaskFactory which means "running" and checks whether it is non-periodic task.

func (*TaskFactory) IsAnyTaskRunning

func (t *TaskFactory) IsAnyTaskRunning() bool

IsAnyTaskRunning returns true when any task exists in TaskFactory, otherwise false.

func (*TaskFactory) RemoveTaskByName

func (t *TaskFactory) RemoveTaskByName(name string)

type TaskFunction

type TaskFunction func()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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