handler

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const HttpExecTimeout = 300

Variables

This section is empty.

Functions

func CreateJob

func CreateJob(j *Job) cron.FuncJob

func GetJobIDFromKey

func GetJobIDFromKey(key string) int

func JobKey

func JobKey(nodeUUID string, jobId int) string

func RunPresetScript

func RunPresetScript(script *models.Script) (result string, err error)

func UpdateJobLog

func UpdateJobLog(jobLogId int, start time.Time, output string, retry int, success bool) error

func WatchJobs

func WatchJobs(nodeUUID string) clientv3.WatchChan

func WatchOnce

func WatchOnce() clientv3.WatchChan

Execute the job immediately value If a single node is executed, the value is nodeUUID If the node where the job is located needs to be executed, the value is null ""

func WatchProc

func WatchProc(nodeUUID string) clientv3.WatchChan

func WatchSystem

func WatchSystem(nodeUUID string) clientv3.WatchChan

Types

type CMDHandler

type CMDHandler struct {
}

func (*CMDHandler) Run

func (c *CMDHandler) Run(job *Job) (result string, err error)

type HTTPHandler

type HTTPHandler struct {
}

func (*HTTPHandler) Run

func (h *HTTPHandler) Run(job *Job) (result string, err error)

type Handler

type Handler interface {
	Run(job *Job) (string, error)
}

func CreateHandler

func CreateHandler(j *Job) Handler

type Job

type Job struct {
	*models.Job
}

func GetJobAndRev

func GetJobAndRev(nodeUUID string, jobId int) (job *Job, rev int64, err error)

func (*Job) CreateJobLog

func (j *Job) CreateJobLog() (int, error)

func (*Job) Fail

func (j *Job) Fail(jobLogId int, start time.Time, errMsg string, retry int) error

func (*Job) RunWithRecovery

func (j *Job) RunWithRecovery()

func (*Job) Success

func (j *Job) Success(jobLogId int, start time.Time, output string, retry int) error

type JobProc

type JobProc struct {
	*models.JobProc
}

Information about the current task in execution key: /crony/proc/<node_uuid>/<job_id>/pid</job_id></node_uuid> value: indicates the start execution time The key expires automatically to prevent the key from being cleared after the process exits unexpectedly. The expiration time can be configured

func GetProcFromKey

func GetProcFromKey(key string) (proc *JobProc, err error)

func (*JobProc) Key

func (p *JobProc) Key() string

func (*JobProc) Start

func (p *JobProc) Start() error

func (*JobProc) Stop

func (p *JobProc) Stop()

type Jobs

type Jobs map[int]*Job

func GetJobs

func GetJobs(nodeUUID string) (jobs Jobs, err error)

Jump to

Keyboard shortcuts

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