-
Notifications
You must be signed in to change notification settings - Fork 212
/
config.go
54 lines (47 loc) · 1.62 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
// Package config provides configuration for GRPC and HTTP api servers
package grpcserver
import (
"time"
)
type Config struct {
PublicServices []Service `mapstructure:"grpc-public-services"`
PublicListener string `mapstructure:"grpc-public-listener"`
PrivateServices []Service `mapstructure:"grpc-private-services"`
PrivateListener string `mapstructure:"grpc-private-listener"`
GrpcSendMsgSize int `mapstructure:"grpc-send-msg-size"`
GrpcRecvMsgSize int `mapstructure:"grpc-recv-msg-size"`
JSONListener string `mapstructure:"grpc-json-listener"`
SmesherStreamInterval time.Duration
}
type Service = string
const (
Admin Service = "admin"
Debug Service = "debug"
GlobalState Service = "global"
Mesh Service = "mesh"
Transaction Service = "transaction"
Activation Service = "activation"
Smesher Service = "smesher"
Node Service = "node"
)
// DefaultConfig defines the default configuration options for api.
func DefaultConfig() Config {
return Config{
PublicServices: []Service{Debug, GlobalState, Mesh, Transaction, Node},
PublicListener: "0.0.0.0:9092",
PrivateServices: []Service{Admin, Smesher},
PrivateListener: "127.0.0.1:9093",
JSONListener: "",
GrpcSendMsgSize: 1024 * 1024 * 10,
GrpcRecvMsgSize: 1024 * 1024 * 10,
SmesherStreamInterval: time.Second,
}
}
// DefaultTestConfig returns the default config for tests.
func DefaultTestConfig() Config {
conf := DefaultConfig()
conf.PublicListener = "127.0.0.1:19092"
conf.PrivateListener = "127.0.0.1:19093"
conf.JSONListener = "127.0.0.1:19094"
return conf
}