Skip to content

Commit acc8e53

Browse files
committed
debug args
1 parent 0fffafd commit acc8e53

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

setup/args.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,26 @@ import (
55
"strconv"
66
)
77

8+
type debug struct {
9+
Event bool `json:"event"`
10+
Stats bool `json:"stats"`
11+
}
12+
813
type args struct {
914
StatsFrequency int `json:"stats_frequency"`
1015
EventEndpoint string `json:"event_endpoint"`
1116
HealthCheckEndpoint string `json:"healthcheck_endpoint"`
17+
Debug debug `json:"debug"`
1218
}
1319

1420
func GetArgs() *args {
1521
return &args{
1622
StatsFrequency: getIntValue(30, "STATS_FREQUENCY"),
1723
EventEndpoint: getStringValue("http://app:8080/events", "EVENT_ENDPOINT"),
1824
HealthCheckEndpoint: getStringValue("http://app:8080/version", "HEALTH_CHECK_ENDPOINT"),
25+
Debug: debug{
26+
Event: getBooleanValue(false, "DEBUG_EVENT"),
27+
Stats: getBooleanValue(false, "DEBUG_STATS")},
1928
}
2029
}
2130

@@ -28,6 +37,19 @@ func getStringValue(defValue string, varName string) string {
2837
return value
2938
}
3039

40+
func getBooleanValue(defValue bool, varName string) bool {
41+
value := defValue
42+
env := os.Getenv(varName)
43+
if len(env) > 0 {
44+
i, err := strconv.ParseBool(env)
45+
if err != nil {
46+
return false
47+
}
48+
value = i
49+
}
50+
return value
51+
}
52+
3153
func getIntValue(defValue int, varName string) int {
3254
value := defValue
3355
env := os.Getenv(varName)

0 commit comments

Comments
 (0)