-
Notifications
You must be signed in to change notification settings - Fork 0
/
load.go
36 lines (30 loc) · 901 Bytes
/
load.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
package cmd
import (
"errors"
"github.com/spf13/cobra"
"github.com/kirillgrachoff/load_tester/pkg/net/multi_get"
)
var (
count int
keepAlive bool
sleepOnError bool
)
// loadCmd represents the load command
var loadCmd = &cobra.Command{
Use: "load host... [ -c count ]",
Short: "Start load test",
Long: `Start load test with given parameters`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return errors.New("sources not specified")
}
client := multi_get.NewClient(count, args, keepAlive, sleepOnError)
return client.Run(cmd.Context())
},
}
func init() {
rootCmd.AddCommand(loadCmd)
loadCmd.Flags().IntVarP(&count, "count", "c", 10, "parallel GETs count")
loadCmd.Flags().BoolVarP(&keepAlive, "keep-alive", "a", false, "do not close connection")
loadCmd.Flags().BoolVar(&sleepOnError, "sleep-on-error", false, "sleep on error")
}