Skip to content

Commit

Permalink
Merge pull request #259 from CAFxX/cafxx-lb-strategy
Browse files Browse the repository at this point in the history
add(cmd/ghz): expose `--lb-strategy`
  • Loading branch information
bojand authored Feb 12, 2021
2 parents efd193d + 4a9ef92 commit ce92238
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/ghz/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ var (
isEnableCompressionSet = false
enableCompression = kingpin.Flag("enable-compression", "Enable Gzip compression on requests.").
Short('e').Default("false").IsSetByUser(&isEnableCompressionSet).Bool()

isLBStrategySet = false
lbStrategy = kingpin.Flag("lb-strategy", "Client load balancing strategy.").
PlaceHolder(" ").IsSetByUser(&isLBStrategySet).String()
)

func main() {
Expand Down Expand Up @@ -471,6 +475,7 @@ func createConfigFromArgs(cfg *runner.Config) error {
cfg.CStepDuration = runner.Duration(*cStepDuration)
cfg.CMaxDuration = runner.Duration(*cMaxDuration)
cfg.CountErrors = *countErrors
cfg.LBStrategy = *lbStrategy

return nil
}
Expand Down Expand Up @@ -646,6 +651,10 @@ func mergeConfig(dest *runner.Config, src *runner.Config) error {
dest.Host = src.Host
}

if isLBStrategySet {
dest.LBStrategy = src.LBStrategy
}

// load

if isAsyncSet {
Expand Down
1 change: 1 addition & 0 deletions runner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ type Config struct {
LoadStep int `json:"load-step" toml:"load-step" yaml:"load-step"`
LoadStepDuration Duration `json:"load-step-duration" toml:"load-step-duration" yaml:"load-step-duration"`
LoadMaxDuration Duration `json:"load-max-duration" toml:"load-max-duration" yaml:"load-max-duration"`
LBStrategy string `json:"lb-strategy" toml:"lb-strategy" yaml:"lb-strategy"`
}

func checkData(data interface{}) error {
Expand Down
1 change: 1 addition & 0 deletions runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,7 @@ func fromConfig(cfg *Config) []Option {
WithLoadStepDuration(time.Duration(cfg.LoadStepDuration)),
WithLoadEnd(cfg.LoadEnd),
WithLoadDuration(time.Duration(cfg.LoadMaxDuration)),
WithClientLoadBalancing(cfg.LBStrategy),
WithAsync(cfg.Async),
WithConcurrencySchedule(cfg.CSchedule),
WithConcurrencyStart(cfg.CStart),
Expand Down

0 comments on commit ce92238

Please sign in to comment.