forked from influxdata/influxdb
/
config.go
41 lines (35 loc) · 993 Bytes
/
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
package storage
import (
"github.com/influxdata/influxdb/monitor/diagnostics"
)
const (
// DefaultBindAddress is the default address to bind to.
DefaultBindAddress = ":8082"
)
// Config represents a configuration for a HTTP service.
type Config struct {
Enabled bool `toml:"enabled"`
LogEnabled bool `toml:"log-enabled"` // verbose logging
BindAddress string `toml:"bind-address"`
}
// NewConfig returns a new Config with default settings.
func NewConfig() Config {
return Config{
Enabled: false,
LogEnabled: true,
BindAddress: DefaultBindAddress,
}
}
// Diagnostics returns a diagnostics representation of a subset of the Config.
func (c Config) Diagnostics() (*diagnostics.Diagnostics, error) {
if !c.Enabled {
return diagnostics.RowFromMap(map[string]interface{}{
"enabled": false,
}), nil
}
return diagnostics.RowFromMap(map[string]interface{}{
"enabled": true,
"log-enabled": c.LogEnabled,
"bind-address": c.BindAddress,
}), nil
}