Skip to content

Commit 7839288

Browse files
authored
Merge pull request #12 from kushthedude/api
feat: Restructure nighthawk api to resolve conflict with wrk2
2 parents 59ae7e1 + 0b81094 commit 7839288

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Package api defines nighthawk runner and config
2-
package api
1+
// Package apinighthawk defines nighthawk runner and config
2+
package apinighthawk
33

44
import (
55
"fmt"
@@ -14,8 +14,8 @@ import (
1414
// NighthawkConfig describes the configuration structure for loadtest
1515
type NighthawkConfig struct {
1616
Thread int
17-
DurationInSeconds int
18-
QPS int
17+
DurationInSeconds float64
18+
QPS float64
1919
URL string
2020
}
2121

@@ -37,8 +37,8 @@ func NighthawkRun(config *NighthawkConfig) ([]byte, error) {
3737
return nil, err
3838
}
3939

40-
duration := strconv.Itoa(config.DurationInSeconds)
41-
qps := strconv.Itoa(config.QPS)
40+
duration := strconv.FormatFloat(config.DurationInSeconds, 'f', -1, 64)
41+
qps := strconv.FormatFloat(config.QPS, 'f', -1, 64)
4242
c := strconv.Itoa(config.Thread)
4343

4444
args := []string{"--rps " + qps, "--concurrency " + c, "--duration " + duration, rURL.String(), "--output-format json"}

cmd/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/layer5io/nighthawk-go/api"
7+
"github.com/layer5io/nighthawk-go/apinighthawk"
88
"github.com/pkg/errors"
99
log "github.com/sirupsen/logrus"
1010
)
@@ -21,14 +21,14 @@ func init() {
2121
}
2222
func main() {
2323
// Duration in seconds nighthawk default format
24-
testConfig := &api.NighthawkConfig{
24+
testConfig := &apinighthawk.NighthawkConfig{
2525
Thread: 1,
2626
DurationInSeconds: 5,
2727
QPS: 1,
2828
URL: "https://www.github.com",
2929
}
3030

31-
result, err := api.NighthawkRun(testConfig)
31+
result, err := apinighthawk.NighthawkRun(testConfig)
3232

3333
if err != nil {
3434
msg := "Failed to run load-test"

0 commit comments

Comments
 (0)