job

package
v0.0.0-...-977965f Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JobKindGeneric : Kind of generic job
	JobKindGeneric = "Generic"
	// JobKindScheduled : Kind of scheduled job
	JobKindScheduled = "Scheduled"
	// JobKindPeriodic : Kind of periodic job
	JobKindPeriodic = "Periodic"
)
View Source
const (
	// JobStatusPending   : job status pending
	JobStatusPending = "Pending"
	// JobStatusRunning   : job status running
	JobStatusRunning = "Running"
	// JobStatusStopped   : job status stopped
	JobStatusStopped = "Stopped"
	// JobStatusCancelled : job status cancelled
	JobStatusCancelled = "Cancelled"
	// JobStatusError     : job status error
	JobStatusError = "Error"
	// JobStatusSuccess   : job status success
	JobStatusSuccess = "Success"
	// JobStatusScheduled : job status scheduled
	JobStatusScheduled = "Scheduled"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckInFunc

type CheckInFunc func(message string)

CheckInFunc is designed for job to report more detailed progress info

type CheckOPCmdFunc

type CheckOPCmdFunc func() (string, bool)

CheckOPCmdFunc is the function to check if the related operation commands like STOP or CANCEL is fired for the specified job. If yes, return the command code for job to determine if take corresponding action.

type Interface

type Interface interface {
	// Declare how many times the job can be retried if failed.
	//
	// Return:
	// uint: the failure count allowed. If it is set to 0, then default value 4 is used.
	MaxFails() uint

	// Tell the worker pool if retry the failed job when the fails is
	// still less that the number declared by the method 'MaxFails'.
	//
	// Returns:
	//  true for retry and false for none-retry
	ShouldRetry() bool

	// Indicate whether the parameters of job are valid.
	//
	// Return:
	// error if parameters are not valid. NOTES: If no parameters needed, directly return nil.
	Validate(params map[string]interface{}) error

	// Run the business logic here.
	// The related arguments will be injected by the workerpool.
	//
	// ctx env.JobContext            : Job execution context.  定义的 3 个函数
	// params map[string]interface{} : parameters with key-pair style for the job execution.
	//
	// Returns:
	//  error if failed to run. NOTES: If job is stopped or cancelled, a specified error should be returned
	//
	// 真正的业务逻辑
	Run(ctx env.JobContext, params map[string]interface{}) error
}

Interface defines the related injection and run entry methods. 定义具体 job 的一些共有方法,如最大失败次数,尝试次数,验证参数合法性,运行 job

type LaunchJobFunc

type LaunchJobFunc func(req models.JobRequest) (models.JobStats, error)

LaunchJobFunc is designed to launch sub jobs in the job 用来启动一个 job 中的子 job

Directories

Path Synopsis
gc

Jump to

Keyboard shortcuts

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