Configuration

How to configuration

配置为两份文件分别为 service config 和 registry config

  • service config 关注服务启停以及声明周期中需要的各类配置
  • registry config 关注服务注册相关配置

server config definition

 1// Service 为一个服务的全部配置
 2message Service {
 3    string name = 1;
 4    string version = 2;
 5    optional Server http = 3;
 6    optional Server grpc = 4;
 7    Log log = 5;
 8    map<string, string> metadata = 6;
 9    Redis redis = 7;
10    MQ mq = 8;
11}
12
13message Server {
14    string scheme = 1;
15    string addr = 2;
16    int32 port = 3;
17}
18
19
20enum Level {
21    DEBUG = 0;
22    INFO = 1;
23    WARING = 2;
24    ERROR = 3;
25    FATAL = 4;
26}
27
28message Log {
29    optional string log_path = 1;
30    repeated Level level = 2;
31}
32
33message Redis {
34    string addr = 1;
35    string password = 2;
36    int32 max_conns = 3;
37    int32 min_idle_conns = 4;
38    google.protobuf.Duration dial_timeout = 5;
39    google.protobuf.Duration idle_timeout = 6;
40}
41
42message MQ {
43    repeated string addr = 1;
44    int32 max_retry = 2;
45}

registry config definition

 1message RegistryInfo {
 2    repeated string addr = 1;
 3    string scheme = 2;
 4    google.protobuf.Duration dial_timeout_sec = 3;
 5    google.protobuf.Duration dial_keep_alive_time_sec = 4;
 6    google.protobuf.Duration dial_keep_alive_timeout_sec = 5;
 7}
 8
 9message Registry {
10    string name = 1;
11    oneof reg {
12        RegistryInfo consul = 2;
13        RegistryInfo etcd = 3;
14    }
15}