generated from rizalgowandy/library-template-go
-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
option.go
60 lines (50 loc) · 1.43 KB
/
option.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
package cronx
import (
"time"
"github.com/rizalgowandy/cronx/storage"
"github.com/robfig/cron/v3"
)
// Option represents a modification to the default behavior of the manager.
type Option func(*Manager)
// WithLocation overrides the timezone of the cron instance.
func WithLocation(loc *time.Location) Option {
return func(m *Manager) {
m.location = loc
}
}
// WithParser overrides the parser used for interpreting job schedules.
func WithParser(p cron.ScheduleParser) Option {
return func(m *Manager) {
m.parser = p
}
}
// WithInterceptor specifies Job wrappers to apply to all jobs added to this cron.
func WithInterceptor(interceptors ...Interceptor) Option {
return func(m *Manager) {
m.interceptor = Chain(interceptors...)
}
}
// WithAutoStartDisabled prevent the cron job from actually running.
func WithAutoStartDisabled() Option {
return func(m *Manager) {
m.autoStart = false
}
}
// WithLowPriorityDownJobs puts the down jobs at the bottom of the list.
func WithLowPriorityDownJobs() Option {
return func(m *Manager) {
m.highPriorityDownJobs = false
}
}
// WithStorage determines the reader and writer for historical data.
func WithStorage(client storage.Client) Option {
return func(m *Manager) {
m.storage = client
}
}
// WithAlerter determines the alerter used to send notification for high latency job run detected.
func WithAlerter(client AlerterItf) Option {
return func(m *Manager) {
m.alerter = client
}
}