-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
57 lines (46 loc) · 1.35 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
57
package config
import "github.com/BurntSushi/toml"
import "fmt"
// This is the base Config type for hermes. Extend as needed.
type Config struct {
Title string
Cache CacheConfig `toml:"cache"`
Filter FilterConfig `toml:"filter"`
Http HermesHTTP `toml:"http"`
Peers PeerConfig `toml:"peers"`
}
type CacheConfig struct {
ShardCount int `toml:"shards"`
Size int
Lambda float64
}
type FilterConfig struct {
FilterItemCount uint `toml:"default_filter_count"`
Enabled bool
}
type HermesHTTP struct {
Host int
AccessLog string `toml:"access_log_location"`
}
type PeerConfig struct {
Listen int
PeerListenPort int `toml:"peer_listen_port"`
Heartbeat int
MulticastEnabled bool `toml:"multicast_enabled"`
MulticastClusterName string `toml:"multicast_cluster_name"`
MulticastAddress string `toml:"multicast_address"`
MulticastPort int `toml:"multicast_port"`
MulticastAnnounceInterval int `toml:"multicast_announce_interval"`
Nodes []string
}
func LoadConfig(filename string) (*Config, error) {
if filename == "" {
filename = "config.toml"
}
var c Config
if _, err := toml.DecodeFile(filename, &c); err != nil {
return nil, err
}
fmt.Printf("Successfully decoded config file: %s \n", c.Title)
return &c, nil
}