cron

package
v2.1.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PoolSize           = 50                 //连接池容量
	DefaultSMTPConfig  = &mail.SMTPConfig{} //STMP配置
	DefaultEmailConfig = &EmailConfig{}
)
View Source
var (
	SYSJobs    = map[string]Jobx{}
	ErrFailure = errors.New(`Error`)
	//NotRecordPrefixFlag 不记录日志的前缀标识
	NotRecordPrefixFlag = `--/ignore/--`
)
View Source
var (
	ErrIncorrectRecipient = errors.New(`The recipient's email address is incorrect`)
)

Functions

func AddJob

func AddJob(spec string, job *Job) bool

func AddSYSJob

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

func Close

func Close()

func CmdParams

func CmdParams(command string) []string

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 InitialMailTpl

func InitialMailTpl()

func MailTpl

func MailTpl() *template.Template

func MainCron

func MainCron(mustStart bool) *cron.Cron

func NewCmdRec

func NewCmdRec(max uint64) *cmdRec

func Parse

func Parse(spec string) error

func RemoveJob

func RemoveJob(id uint)

func Running

func Running() bool

func SendMail

func SendMail(toEmail string, toUsername string, title string, content []byte, ccList ...string) error

func SendMailWithID

func SendMailWithID(id uint64, toEmail string, toUsername string, title string, content []byte, ccList ...string) error

Types

type EmailConfig

type EmailConfig struct {
	Template  string
	Sender    string
	Engine    string
	Timeout   int64
	QueueSize int
}

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.Task) (*Job, error)

func (*Job) Id

func (j *Job) Id() uint

func (*Job) LogData

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

func (*Job) LogID

func (j *Job) LogID() uint64

func (*Job) Name

func (j *Job) Name() string

func (*Job) Run

func (j *Job) Run()

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 interface {
	io.Writer
	String() string
	Bytes() []byte
}

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

Jump to

Keyboard shortcuts

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