github.com/Tri-stone/burrow@v0.25.0/rpc/config.go (about) 1 package rpc 2 3 import "fmt" 4 5 // 'localhost' gets interpreted as ipv6 6 // TODO: revisit this 7 const localhost = "127.0.0.1" 8 9 type RPCConfig struct { 10 Info *ServerConfig `json:",omitempty" toml:",omitempty"` 11 Profiler *ServerConfig `json:",omitempty" toml:",omitempty"` 12 GRPC *ServerConfig `json:",omitempty" toml:",omitempty"` 13 Metrics *MetricsConfig `json:",omitempty" toml:",omitempty"` 14 } 15 16 type ServerConfig struct { 17 Enabled bool 18 ListenAddress string 19 } 20 21 type MetricsConfig struct { 22 ServerConfig 23 MetricsPath string 24 BlockSampleSize int 25 } 26 27 func DefaultRPCConfig() *RPCConfig { 28 return &RPCConfig{ 29 Info: DefaultInfoConfig(), 30 Profiler: DefaultProfilerConfig(), 31 GRPC: DefaultGRPCConfig(), 32 Metrics: DefaultMetricsConfig(), 33 } 34 } 35 36 func DefaultInfoConfig() *ServerConfig { 37 return &ServerConfig{ 38 Enabled: true, 39 ListenAddress: fmt.Sprintf("tcp://%s:26658", localhost), 40 } 41 } 42 43 func DefaultGRPCConfig() *ServerConfig { 44 return &ServerConfig{ 45 Enabled: true, 46 ListenAddress: fmt.Sprintf("tcp://%s:10997", localhost), 47 } 48 } 49 50 func DefaultProfilerConfig() *ServerConfig { 51 return &ServerConfig{ 52 Enabled: false, 53 ListenAddress: fmt.Sprintf("tcp://%s:6060", localhost), 54 } 55 } 56 57 func DefaultMetricsConfig() *MetricsConfig { 58 return &MetricsConfig{ 59 ServerConfig: ServerConfig{ 60 Enabled: false, 61 ListenAddress: fmt.Sprintf("tcp://%s:9102", localhost), 62 }, 63 MetricsPath: "/metrics", 64 BlockSampleSize: 100, 65 } 66 }