-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparams.go
39 lines (31 loc) · 1.05 KB
/
params.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
package winterfx
import (
"flag"
"time"
)
// Params params
type Params struct {
// Listen listen address
Listen string
// PathReadiness readiness check path
PathReadiness string
// PathLiveness liveness path
PathLiveness string
// PathMetrics metrics path
PathMetrics string
// DelayStart delay start
DelayStart time.Duration
// DelayStop delay stop
DelayStop time.Duration
}
// DecodeParams create Params from flag.FlagSet
func DecodeParams(fset *flag.FlagSet) (p *Params) {
p = &Params{}
fset.StringVar(&p.Listen, "server.listen", ":8080", "server listen address")
fset.StringVar(&p.PathReadiness, "server.path.readiness", "/debug/ready", "server path readiness")
fset.StringVar(&p.PathLiveness, "server.path.liveness", "/debug/alive", "server path liveness")
fset.StringVar(&p.PathMetrics, "server.path.metrics", "/debug/metrics", "server path metrics")
fset.DurationVar(&p.DelayStart, "server.delay.start", time.Second*3, "server delay start")
fset.DurationVar(&p.DelayStop, "server.delay.stop", time.Second*3, "server delay stop")
return p
}