Documentation
¶
Index ¶
- type Dcron
- func (d *Dcron) AddFunc(jobName, cronStr string, cmd func()) (err error)
- func (d *Dcron) AddJob(jobName, cronStr string, job Job) (err error)
- func (d *Dcron) GetLogger() Logger
- func (d *Dcron) Remove(jobName string)
- func (d *Dcron) Run()
- func (d *Dcron) SetLogger(logger Logger)
- func (d *Dcron) Start()
- func (d *Dcron) Stop()
- type Hash
- type INodePool
- type Job
- type JobWarpper
- type LogfLogger
- type Logger
- type Map
- type NodePool
- type Option
- func CronOptionChain(wrappers ...cron.JobWrapper) Option
- func CronOptionLocation(loc *time.Location) Option
- func CronOptionParser(p cron.ScheduleParser) Option
- func CronOptionSeconds() Option
- func WithHashReplicas(d int) Option
- func WithLogger(logger Logger) Option
- func WithNodeUpdateDuration(d time.Duration) Option
- func WithPrintLogInfo() Option
- func WithRecoverFunc(recoverFunc RecoverFuncType) Option
- type PrintfLogger
- type PrintfLoggerFromLogfLogger
- type RecoverFuncType
- type StableJob
- type StdLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dcron ¶
type Dcron struct { ServerName string RecoverFunc RecoverFuncType // contains filtered or unexported fields }
Dcron is main struct
func NewDcronWithOption ¶
NewDcronWithOption create a Dcron with Dcron Option
type INodePool ¶
type JobWarpper ¶
type JobWarpper struct { ID cron.EntryID Dcron *Dcron Name string CronStr string Func func() Job Job }
JobWarpper is a job warpper
type LogfLogger ¶
type LogfLogger interface {
Logf(string, ...interface{})
}
type Logger ¶
type Logger interface { PrintfLogger Infof(string, ...interface{}) Warnf(string, ...interface{}) Errorf(string, ...interface{}) }
func NewLoggerForTest ¶
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
type NodePool ¶
type NodePool struct {
// contains filtered or unexported fields
}
NodePool is a node pool
func (*NodePool) CheckJobAvailable ¶
CheckJobAvailable Check if this job can be run in this node.
type Option ¶
type Option func(*Dcron)
Option is Dcron Option
func CronOptionChain ¶
func CronOptionChain(wrappers ...cron.JobWrapper) Option
CronOptionChain is Warp cron with chain
func CronOptionLocation ¶
CronOptionLocation is warp cron with location
func CronOptionParser ¶
func CronOptionParser(p cron.ScheduleParser) Option
CronOptionParser is warp cron with schedules.
func CronOptionSeconds ¶
func CronOptionSeconds() Option
CronOptionSeconds is warp cron with seconds
func WithNodeUpdateDuration ¶
WithNodeUpdateDuration set node update duration
func WithRecoverFunc ¶
func WithRecoverFunc(recoverFunc RecoverFuncType) Option
WithRecoverFunc You can defined yourself recover function to make the job will be added to your dcron when the process restart
type PrintfLogger ¶
type PrintfLogger interface {
Printf(string, ...interface{})
}
func NewPrintfLoggerFromLogfLogger ¶
func NewPrintfLoggerFromLogfLogger(logger LogfLogger) PrintfLogger
type PrintfLoggerFromLogfLogger ¶
type PrintfLoggerFromLogfLogger struct {
Log LogfLogger
}
func (*PrintfLoggerFromLogfLogger) Printf ¶
func (l *PrintfLoggerFromLogfLogger) Printf(fmt string, args ...interface{})
type RecoverFuncType ¶
type RecoverFuncType func(d *Dcron)
type StableJob ¶
type StableJob interface { Job GetCron() string Serialize() ([]byte, error) UnSerialize([]byte) error }
StableJob This type of Job will be recovered in a node of service restarting.
type StdLogger ¶
type StdLogger struct {
Log PrintfLogger
}