@@ -5,17 +5,26 @@ import (
5
5
"strconv"
6
6
)
7
7
8
+ type debug struct {
9
+ Event bool `json:"event"`
10
+ Stats bool `json:"stats"`
11
+ }
12
+
8
13
type args struct {
9
14
StatsFrequency int `json:"stats_frequency"`
10
15
EventEndpoint string `json:"event_endpoint"`
11
16
HealthCheckEndpoint string `json:"healthcheck_endpoint"`
17
+ Debug debug `json:"debug"`
12
18
}
13
19
14
20
func GetArgs () * args {
15
21
return & args {
16
22
StatsFrequency : getIntValue (30 , "STATS_FREQUENCY" ),
17
23
EventEndpoint : getStringValue ("http://app:8080/events" , "EVENT_ENDPOINT" ),
18
24
HealthCheckEndpoint : getStringValue ("http://app:8080/version" , "HEALTH_CHECK_ENDPOINT" ),
25
+ Debug : debug {
26
+ Event : getBooleanValue (false , "DEBUG_EVENT" ),
27
+ Stats : getBooleanValue (false , "DEBUG_STATS" )},
19
28
}
20
29
}
21
30
@@ -28,6 +37,19 @@ func getStringValue(defValue string, varName string) string {
28
37
return value
29
38
}
30
39
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
+
31
53
func getIntValue (defValue int , varName string ) int {
32
54
value := defValue
33
55
env := os .Getenv (varName )
0 commit comments