-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoption.go
43 lines (36 loc) · 1.03 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
package gawe
import "time"
// Option represents the workers controller options
type Option func(*Engine)
// WithMaxAttempts sets the max attempts of a job execution
func WithMaxAttempts(maxAttempts int) Option {
return func(e *Engine) {
e.maxAttempts = maxAttempts
}
}
// WithMaxQueueSize sets the max queue of the jobs to be execute by the workers
func WithMaxQueueSize(maxQueueSize int) Option {
return func(e *Engine) {
e.maxQueueSize = maxQueueSize
}
}
// WithMaxWorkers sets the max workers can be run in the background
func WithMaxWorkers(maxWorkers int) Option {
return func(e *Engine) {
e.maxWorkers = maxWorkers
}
}
// WithInactivityTimeout sets the lifetime timeout of a worker since the last job execution
func WithInactivityTimeout(inactivityTimeout time.Duration) Option {
return func(e *Engine) {
e.inactivityTimeout = inactivityTimeout
}
}
// WithPlugins sets the plugins
func WithPlugins(plugins ...Plugin) Option {
return func(e *Engine) {
for _, p := range plugins {
e.plugins = append(e.plugins, p)
}
}
}