-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoption.go
More file actions
55 lines (47 loc) · 994 Bytes
/
option.go
File metadata and controls
55 lines (47 loc) · 994 Bytes
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
package beat
import (
"context"
"time"
)
type option func(*Beat)
// WithParser allows to specify custom parser.
func WithParser(p ScheduleParser) option {
return func(b *Beat) {
b.parser = p
}
}
// WithRecover allows to enable panic recovery in job.
func WithRecovery() option {
return func(b *Beat) {
b.withRecovery = true
}
}
// WithLocation allows to specify custom location.
func WithLocation(location *time.Location) option {
return func(b *Beat) {
b.location = location
}
}
// WithLogger allows to specify custom logger.
func WithLogger(log Logger) option {
return func(b *Beat) {
b.log = log
}
}
// WithContext allows to specify custom context.
func WithContext(ctx context.Context) option {
return func(b *Beat) {
b.ctx = ctx
}
}
// WithMaxGoroutines allows to specify max number of goroutines.
//
// Default is 0. 0 means no limit
func WithMaxGoroutines(max int) option {
return func(b *Beat) {
if max < 0 {
max = 0
}
b.maxGoroutines = max
}
}