-
Notifications
You must be signed in to change notification settings - Fork 3
/
scheduler.partial.go
73 lines (60 loc) · 1.49 KB
/
scheduler.partial.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package scheduler
import (
"github.com/GoFarsi/scheduler/helper"
"github.com/GoFarsi/scheduler/types"
"time"
)
// Every schedules a new periodic job running in specific interval
func Every(interval uint64) *Job {
return defaultScheduler.Every(interval)
}
// RunPending runs all pending jobs
func RunPending() {
defaultScheduler.RunPending()
}
// RunAll runs all jobs
func RunAll() {
defaultScheduler.RunAll()
}
// RunAllWithDelay runs all jobs with a delay
func RunAllWithDelay(d int) {
defaultScheduler.RunAllWithDelay(d)
}
// Start run all jobs that are scheduled to run
func Start() chan bool {
return defaultScheduler.Start()
}
// Clear all scheduled jobs
func Clear() {
defaultScheduler.Clear()
}
// Remove a specific job
func Remove(j interface{}) {
defaultScheduler.Remove(j)
}
// ChangeTimeLocation change the location of a time
func ChangeTimeLocation(location *time.Location) {
types.TimeZone = location
defaultScheduler.ChangeLocation(location)
}
// Scheduled checks if specific job j was already added
func Scheduled(j interface{}) bool {
for _, jb := range defaultScheduler.JobList {
if jb.JobFunction == helper.GetFunctionName(j) {
return true
}
}
return false
}
// NextRun gets the next running time
func NextRun() (job *Job, time time.Time) {
return defaultScheduler.NextRun()
}
// Jobs returns the list of job from the defaultScheduler
func Jobs() []*Job {
return defaultScheduler.Jobs()
}
// SetLocker sets a locker implementation
func SetLocker(l Locker) {
jobLocker = l
}