MCPcopy
hub / github.com/robfig/cron / Schedule

Method Schedule

cron.go:158–174  ·  view source on GitHub ↗

Schedule adds a Job to the Cron to be run on the given schedule. The job is wrapped with the configured Chain.

(schedule Schedule, cmd Job)

Source from the content-addressed store, hash-verified

156// Schedule adds a Job to the Cron to be run on the given schedule.
157// The job is wrapped with the configured Chain.
158func (c *Cron) Schedule(schedule Schedule, cmd Job) EntryID {
159 c.runningMu.Lock()
160 defer c.runningMu.Unlock()
161 c.nextID++
162 entry := &Entry{
163 ID: c.nextID,
164 Schedule: schedule,
165 WrappedJob: c.chain.Then(cmd),
166 Job: cmd,
167 }
168 if !c.running {
169 c.entries = append(c.entries, entry)
170 } else {
171 c.add <- entry
172 }
173 return entry.ID
174}
175
176// Entries returns a snapshot of the cron entries.
177func (c *Cron) Entries() []Entry {

Callers 5

AddJobMethod · 0.95
TestJobFunction · 0.80
TestScheduleAfterRemovalFunction · 0.80

Calls 1

ThenMethod · 0.80

Tested by 4

TestJobFunction · 0.64
TestScheduleAfterRemovalFunction · 0.64