-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
56 lines (45 loc) · 1.18 KB
/
config.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
package config
// This package provides very simple configuration semantics and is designed to be a dependency
// for the rest of the app and any of its component packages.
import (
"flag"
"os"
)
// AppName app metadata
const AppName = "prometheus2appoptics"
var (
globalConf *Config
bindPort int
)
func init() {
flag.IntVar(&bindPort, "bind-port", 4567, "the port the HTTP server binds to")
flag.Parse()
globalConf = New()
}
// Config for the reporter
type Config struct {
bindPort int
accessEmail string
}
// New *Config constructor
func New() *Config {
return &Config{
bindPort: bindPort,
}
}
// AccessToken returns a string representing a AppOptics API token
func AccessToken() string {
return os.Getenv("APPOPTICS_TOKEN")
}
// BindPort returns the port number that the service is bound to
func BindPort() int {
return globalConf.bindPort
}
// PushErrorLimit is a hardcoded limit on how many errors will be tolerated before the service stops attempting push
func PushErrorLimit() int {
return 5
}
// SendStats returns true if the application should persist stats over the network to AppOptics, false otherwise
func SendStats() bool {
return os.Getenv("SEND_STATS") != ""
}