forked from codesenberg/bombardier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.go
62 lines (51 loc) · 1.44 KB
/
common.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"errors"
"sort"
"time"
)
const (
decBase = 10
rateLimitInterval = 10 * time.Millisecond
oneSecond = 1 * time.Second
exitFailure = 1
)
var (
version = "unspecified"
emptyConf = config{}
parser = newKingpinParser()
defaultTestDuration = 10 * time.Second
defaultNumberOfConns = uint64(125)
defaultTimeout = 2 * time.Second
httpMethods = []string{
"GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS",
"PATCH",
}
cantHaveBody = []string{"GET", "HEAD"}
errInvalidURL = errors.New(
"No hostname or invalid scheme")
errInvalidNumberOfConns = errors.New(
"Invalid number of connections(must be > 0)")
errInvalidNumberOfRequests = errors.New(
"Invalid number of requests(must be > 0)")
errInvalidTestDuration = errors.New(
"Invalid test duration(must be >= 1s)")
errNegativeTimeout = errors.New(
"Timeout can't be negative")
errBodyNotAllowed = errors.New(
"GET and HEAD requests cannot have body")
errNoPathToCert = errors.New(
"No Path to TLS Client Certificate")
errNoPathToKey = errors.New(
"No Path to TLS Client Certificate Private Key")
errZeroRate = errors.New(
"Rate can't be less than 1")
errBodyProvidedTwice = errors.New("Use either --body or --body-file")
errInvalidHeaderFormat = errors.New("Invalid header format")
errEmptyPrintSpec = errors.New(
"Empty print spec is not a valid print spec")
)
func init() {
sort.Strings(httpMethods)
sort.Strings(cantHaveBody)
}