MCPcopy Create free account
hub / github.com/DoNewsCode/core / New

Function New

cron/cron.go:29–49  ·  view source on GitHub ↗

New returns a new Cron instance.

(config Config)

Source from the content-addressed store, hash-verified

27
28// New returns a new Cron instance.
29func New(config Config) *Cron {
30 c := &Cron{
31 parser: config.Parser,
32 lock: sync.NewCond(&sync.Mutex{}),
33 jobDescriptors: jobDescriptors{},
34 globalMiddleware: config.GlobalOptions,
35 location: config.Location,
36 nextID: 1,
37 }
38 if config.Parser == nil {
39 if config.EnableSeconds {
40 c.parser = cron.NewParser(cron.Second | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow | cron.Descriptor)
41 } else {
42 c.parser = cron.NewParser(cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow | cron.Descriptor)
43 }
44 }
45 if config.Location == nil {
46 c.location = time.Local
47 }
48 return c
49}
50
51// Add adds a new job to the cron scheduler.A list of middleware can be supplied.
52// Note the error returned by the runner will be discarded. It is the user's

Callers 8

cronServeMethod · 0.92
ExampleFunction · 0.92
TestJobOptionFunction · 0.70
TestCron_heapsortFunction · 0.70
TestCron_no_jobFunction · 0.70
TestCron_late_jobFunction · 0.70
TestCron_remove_jobFunction · 0.70

Calls

no outgoing calls

Tested by 7

ExampleFunction · 0.74
TestJobOptionFunction · 0.56
TestCron_heapsortFunction · 0.56
TestCron_no_jobFunction · 0.56
TestCron_late_jobFunction · 0.56
TestCron_remove_jobFunction · 0.56