-
Notifications
You must be signed in to change notification settings - Fork 8
/
worker.go
40 lines (35 loc) · 1.57 KB
/
worker.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
package cmdoptions
import (
"strconv"
"github.com/spf13/pflag"
)
// WorkerOptions for setting up worker parameters
type WorkerOptions struct {
MaxConcurrentActivityPollers int
MaxConcurrentWorkflowPollers int
MaxConcurrentActivities int
MaxConcurrentWorkflowTasks int
}
// AddCLIFlags adds the relevant flags to populate the options struct.
func (m *WorkerOptions) AddCLIFlags(fs *pflag.FlagSet, prefix string) {
fs.IntVar(&m.MaxConcurrentActivityPollers, prefix+"max-concurrent-activity-pollers", 0, "Max concurrent activity pollers")
fs.IntVar(&m.MaxConcurrentWorkflowPollers, prefix+"max-concurrent-workflow-pollers", 0, "Max concurrent workflow pollers")
fs.IntVar(&m.MaxConcurrentActivities, prefix+"max-concurrent-activities", 0, "Max concurrent activities")
fs.IntVar(&m.MaxConcurrentWorkflowTasks, prefix+"max-concurrent-workflow-tasks", 0, "Max concurrent workflow tasks")
}
// ToFlags converts these options to string flags.
func (m *WorkerOptions) ToFlags() (flags []string) {
if m.MaxConcurrentActivityPollers != 0 {
flags = append(flags, "--max-concurrent-activity-pollers", strconv.Itoa(m.MaxConcurrentActivityPollers))
}
if m.MaxConcurrentWorkflowPollers != 0 {
flags = append(flags, "--max-concurrent-workflow-pollers", strconv.Itoa(m.MaxConcurrentWorkflowPollers))
}
if m.MaxConcurrentActivities != 0 {
flags = append(flags, "--max-concurrent-activities", strconv.Itoa(m.MaxConcurrentActivities))
}
if m.MaxConcurrentWorkflowTasks != 0 {
flags = append(flags, "--max-concurrent-workflow-tasks", strconv.Itoa(m.MaxConcurrentWorkflowTasks))
}
return
}