forked from hyperledger-archives/burrow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
75 lines (63 loc) · 1.57 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package rpc
import "fmt"
// 'localhost' gets interpreted as ipv6
// TODO: revisit this
const localhost = "127.0.0.1"
type RPCConfig struct {
Info *ServerConfig `json:",omitempty" toml:",omitempty"`
Profiler *ServerConfig `json:",omitempty" toml:",omitempty"`
GRPC *ServerConfig `json:",omitempty" toml:",omitempty"`
Metrics *MetricsConfig `json:",omitempty" toml:",omitempty"`
}
type ServerConfig struct {
Enabled bool
ListenAddress string
}
type ProfilerConfig struct {
Enabled bool
ListenAddress string
}
type GRPCConfig struct {
Enabled bool
ListenAddress string
}
type MetricsConfig struct {
Enabled bool
ListenAddress string
MetricsPath string
BlockSampleSize int
}
func DefaultRPCConfig() *RPCConfig {
return &RPCConfig{
Info: DefaultInfoConfig(),
Profiler: DefaultProfilerConfig(),
GRPC: DefaultGRPCConfig(),
Metrics: DefaultMetricsConfig(),
}
}
func DefaultInfoConfig() *ServerConfig {
return &ServerConfig{
Enabled: true,
ListenAddress: fmt.Sprintf("tcp://%s:26658", localhost),
}
}
func DefaultGRPCConfig() *ServerConfig {
return &ServerConfig{
Enabled: true,
ListenAddress: fmt.Sprintf("%s:10997", localhost),
}
}
func DefaultProfilerConfig() *ServerConfig {
return &ServerConfig{
Enabled: false,
ListenAddress: fmt.Sprintf("tcp://%s:6060", localhost),
}
}
func DefaultMetricsConfig() *MetricsConfig {
return &MetricsConfig{
Enabled: false,
ListenAddress: fmt.Sprintf("tcp://%s:9102", localhost),
MetricsPath: "/metrics",
BlockSampleSize: 100,
}
}