/
commands.go
82 lines (69 loc) · 3.1 KB
/
commands.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package main
import (
"context"
"time"
)
type Globals struct {
Debug bool `help:"Enable debug mode" short:"D" default:"false"`
DiscoveryURL string `help:"Backend metadata discovery URL" short:"u" default:"http://localhost:2000"`
HTTPPort int `help:"HAProxy HTTP port" default:"8080"`
HTTPSPort int `help:"HAProxy HTTPS port" default:"8443"`
HTTPSPortSNIOnly int `help:"HAProxy HTTPS port for SNI-only traffic" default:"9443"`
HostPrefix string `help:"Hostname prefix" default:"perf-test-hydra"`
Nbackends int `help:"Number of backends per traffic type" short:"n" default:"1"`
OutputDir string `help:"Configuration output directory" short:"o" default:"testrun"`
SocketDir string `help:"Directory for HAProxy's unix domain sockets" default:"/tmp"`
Port int `help:"Port number for backend metadata server" short:"p" default:"2000"`
Profile bool `help:"Record a CPU profile." short:"P"`
TLSReuse bool `help:"Enable TLS session reuse" default:"true"`
Version VersionFlag `help:"Print version information and quit."`
}
type CLI struct {
Globals
GenHosts GenHostsCmd `cmd:"" help:"Generate host names (/etc/hosts compatible)."`
GenProxyConfig GenProxyConfigCmd `cmd:"" help:"Generate HAProxy configuration."`
SyncEnvoyConfig SyncEnvoyConfigCmd `cmd:"" help:"Sync Envoy configuration by starting a Envoy Control Plane."`
GenWorkload GenWorkloadCmd `cmd:"" help:"Generate https://github.com/jmencak/mb requests."`
ServeBackend ServeBackendCmd `cmd:"" help:"Serve backend." hidden:"true"`
ServeBackends ServeBackendsCmd `cmd:"" help:"Serve backends."`
Test TestCmd `cmd:"" help:"Run client test using requests file."`
Version VersionCmd `cmd:"" help:"Print version information and quit."`
}
type ProgramCtx struct {
Context context.Context
Globals
}
type TestCmd struct {
Duration time.Duration `help:"Test duration" short:"d" default:"60s"`
RequestFile string `help:"Request file." short:"i" type:"existingfile"`
}
type GenProxyConfigCmd struct {
EnableHTTP2 bool `default:"true"`
EnableLogging bool `default:"true"`
HealthCheckIntervalInMillis int `default:"1000"`
ListenAddress string `default:""`
Maxconn int `default:"0"`
Nthreads int `default:"4"`
StatsPort int `default:"1936"`
UseUnixDomainSockets bool `default:"true"`
}
type SyncEnvoyConfigCmd struct {
EnableLogging bool `default:"true"`
XdsServerPort int `default:"18000"`
ListenAddress string `default:"127.0.0.1"`
}
type GenHostsCmd struct {
IPAddress string
}
type GenWorkloadCmd struct {
UseProxy bool `default:"true"`
}
type ServeBackendsCmd struct {
ListenAddress string `default:"127.0.0.1"`
}
type ServeBackendCmd struct {
Name string `default:""`
ListenAddress string `default:""`
TrafficType TrafficType `default:""`
}
type VersionCmd struct{}