aboutsummaryrefslogtreecommitdiff
path: root/internal/options/options.go
blob: e98d6ebb101076aeeb35e4d38ed1885f67f1aaa2 (plain)
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
package options

import (
	"flag"
	"time"
)

type Options struct {
	InputFile       string
	NumWorkers      int
	Limit           int
	MaxResponse     int64
	Timeout         time.Duration
	MetricsInterval time.Duration
}

func Parse() (opts Options) {
	flag.StringVar(&opts.InputFile, "i", "", "input file, one domain name per line")
	flag.IntVar(&opts.NumWorkers, "w", 32, "number of parallel workers")
	flag.IntVar(&opts.Limit, "l", 16, "rate-limit that kicks in before handing out work in requests/s")
	flag.Int64Var(&opts.MaxResponse, "r", 128, "max response body size to accept in MiB")
	flag.DurationVar(&opts.Timeout, "t", 10*time.Second, "timeout for each website visit")
	flag.DurationVar(&opts.MetricsInterval, "m", 5*time.Second, "how often to emit metrics")
	flag.Parse()
	return
}