-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce flags for setting worker options such as task poller counts…
… and concurrent execution limits (#31)
- Loading branch information
1 parent
227480a
commit 71bf631
Showing
4 changed files
with
90 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters