common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	API_JOB_LIST   string = "/job"        // GET
	API_JOB_CREATE        = "/job"        // POST
	API_JOB_DELETE        = "/job/{name}" // DELETE
	API_JOB_FETCH         = "/job/{name}" // GET
	API_JOB_KILL          = "/job/{name}" // PUT
	API_JOB_LOG           = "/job/log"    // GET
	API_WORK_LIST         = "/worker"     // GET
)
View Source
const (
	JOB_SAVE_DIR   string = "/cron/jobs/"
	JOB_KILLER_DIR        = "/cron/killer/"
	JOB_LOCK_DIR          = "/cron/lock/"
	JOB_WORKER_DIR        = "/cron/workers/"
)
View Source
const (
	JOB_EVENT_DELETE = iota // 删除任务事件
	JOB_EVENT_SAVE          // 保存任务事件
	JOB_EVENT_KILL          // 强杀任务事件
)

Variables

View Source
var (
	ERROR_LOCK_ALREADY_REQUIRED = errors.New("The Lock has been occupied!")
	ERROR_NO_LOCAL_IP_FOUND     = errors.New("Nic IP not found! ")
)
View Source
var (
	Manage *utils.Container
)

Functions

func BuildResponse

func BuildResponse(errno int, msg string, data interface{}) (resp []byte, err error)

func ExtractJobName

func ExtractJobName(jobKey string) string

func ExtractKillerName

func ExtractKillerName(killerKey string) string

func ExtractWorkerIP

func ExtractWorkerIP(regKey string) string

func InitContainer

func InitContainer() (err error)

Types

type Job

type Job struct {
	Name     string `json:"name"`
	Command  string `json:"command"`
	CronExpr string `json:"cronExpr"`
}

func UnpackJob

func UnpackJob(value []byte) (ret *Job, err error)

type JobEvent

type JobEvent struct {
	EventType int
	Job       *Job
}

func BuildJobEvent

func BuildJobEvent(eventType int, job *Job) (jobEvent *JobEvent)

type JobExecuteInfo

type JobExecuteInfo struct {
	Job        *Job               // the job information
	PlanTime   time.Time          // the plan scheduled time
	RealTime   time.Time          // the real scheduled time
	CancelCtx  context.Context    // the job command is context
	CancelFunc context.CancelFunc // the cancel command func
}

func BuildJobExecuteInfo

func BuildJobExecuteInfo(jobSchedulePlan *JobSchedulePlan) (jobExecuteInfo *JobExecuteInfo)

type JobExecuteResult

type JobExecuteResult struct {
	ExecuteInfo *JobExecuteInfo // the exec status
	Output      []byte          // the script output
	Err         error           // the script error info
	StartTime   time.Time       // the script start time
	EndTime     time.Time       // the script end time
}

type JobLog

type JobLog struct {
	JobName      string `json:"jobName" bson:"jobName"`
	Command      string `json:"command" bson:"command"`
	Err          string `json:"err" bson:"err"`
	Output       string `json:"output" bson:"output"`
	PlanTime     int64  `json:"planTime" bson:"planTime"`
	ScheduleTime int64  `json:"scheduleTime" bson:"scheduleTime"`
	StartTime    int64  `json:"startTime" bson:"startTime"`
	EndTime      int64  `json:"endTime" bson:"endTime"`
}

type JobLogFilter

type JobLogFilter struct {
	JobName string `bson:"jobName"`
}

type JobSchedulePlan

type JobSchedulePlan struct {
	Job      *Job                 // the job information
	Expr     *cronexpr.Expression // the cron expr
	NextTime time.Time            // the next scheduled time
}

func BuildJobSchedulePlan

func BuildJobSchedulePlan(job *Job) (jobSchedulePlan *JobSchedulePlan, err error)

type LogBatch

type LogBatch struct {
	Logs []interface{} // 多条日志
}

type Response

type Response struct {
	Errno int         `json:"errno"`
	Msg   string      `json:"msg"`
	Data  interface{} `json:"data"`
}

type SortLogByStartTime

type SortLogByStartTime struct {
	SortOrder int `bson:"startTime"`
}

Jump to

Keyboard shortcuts

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