cron

package
v2.2.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// SYSJobs 系统Job
	SYSJobs = map[string]Jobx{}

	// ErrFailure 报错:执行失败
	ErrFailure = errors.New(`Error`)

	// Senders 发信程序
	Senders = []func(param.Store) error{}
)
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 (
	PoolSize = 50 //连接池容量
)

Functions

func AddJob

func AddJob(spec string, job *Job) bool

func AddSYSJob

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

AddSYSJob 添加系统Job

func AddSender

func AddSender(sender func(params param.Store) error)

AddSender 添加发信程序

func Close

func Close()

func CmdParams

func CmdParams(command string) []string

func EmailSender

func EmailSender(params param.Store) 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(params param.Store) error

func Parse

func Parse(spec string) error

func RemoveJob

func RemoveJob(id uint)

func Running

func Running() bool

func Send

func Send(params param.Store) (err error)

Send 发送通知/信件

Types

type Job

type Job struct {
	Concurrent bool // 同一个任务是否允许并行执行
	// contains filtered or unexported fields
}

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() int64

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)

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