cron

package
v3.6.4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SendMail 发送Email
	// @param toEmail 收信邮箱
	// @param toUsername 收信人名称
	// @param title 邮件标题
	// @param content 邮件内容
	// @param ccList 抄送地址
	SendMail = send.Mail

	// SendMailWithID 发送Email(带ID参数)
	SendMailWithID = send.MailWithID

	// SendMailWithNoticer 发送Email(带Noticer参数)
	SendMailWithNoticer = send.MailWithNoticer

	// SendMailWithIDAndNoticer 发送Email(带ID和Noticer参数)
	SendMailWithIDAndNoticer = send.MailWithIDAndNoticer

	NewCmdRec = writer.New
)
View Source
var (

	// ErrFailure 报错:执行失败
	ErrFailure = errors.New(`Error`)
)
View Source
var (
	PoolSize = 50 //连接池容量
)

Functions

func AddJob

func AddJob(spec string, job *Job) bool

func AddSender

func AddSender(sender func(alertData *alert.AlertData) error)

AddSender 添加发信程序

func AddSystemJob

func AddSystemJob(name string, fn RunnerGetter, example string, description string)

AddSystemJob 添加系统Job

func Close

func Close()

func CmdParams

func CmdParams(command string) []string

func EmailSender

func EmailSender(alertData *alert.AlertData) error

func GetEntries

func GetEntries(size int) []cron.Entry

func GetEntryById

func GetEntryById(id uint) *cron.Entry

func HistoryJobsRunning

func HistoryJobsRunning() bool

func InitJobs

func InitJobs(ctx context.Context) error

func Initial

func Initial(sizes ...int)

func MainCron

func MainCron(mustStart bool) *cron.Cron

func OtherSender

func OtherSender(alertData *alert.AlertData) error

func Parse

func Parse(spec string) error

func Register

func Register(name string, fn RunnerGetter, example string, description string)

func RemoveJob

func RemoveJob(id uint)

func Running

func Running() bool

func Send

func Send(alertData *alert.AlertData) (err error)

Send 发送通知/信件

Types

type Job

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

Job 定义需要处理的job

func NewCommandJob

func NewCommandJob(ctx context.Context, id uint, name string, command string, dir string, env ...string) *Job

func NewJobFromTask

func NewJobFromTask(ctx context.Context, task *dbschema.NgingTask) (*Job, error)

func (*Job) Id

func (j *Job) Id() uint

func (*Job) LogData

func (j *Job) LogData() *dbschema.NgingTaskLog

func (*Job) LogID

func (j *Job) LogID() uint64

func (*Job) Name

func (j *Job) Name() string

func (*Job) Run

func (j *Job) Run()

Run 运行Job

func (*Job) Status

func (j *Job) Status() int32

type Jobx

type Jobx struct {
	Example      string //">funcName:param"
	Description  string
	RunnerGetter RunnerGetter
}

type OutputWriter

type OutputWriter = writer.OutputWriter

func NewOutputWriter

func NewOutputWriter(sizes ...uint64) OutputWriter

type Runner

type Runner func(timeout time.Duration) (out string, runingErr string, onRunErr error, isTimeout bool)

Runner 命令运行

type RunnerGetter

type RunnerGetter func(string) Runner

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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