From 290636e2e9157f4dd0961761d2526e5b06fa29d1 Mon Sep 17 00:00:00 2001 From: JellyTony Date: Wed, 13 Mar 2024 13:45:56 +0800 Subject: [PATCH] fix --- api/config/v1/config.pb.go | 53 +++++++++++++++++++++++--------------- api/config/v1/config.proto | 12 +++++---- config/config.go | 6 +---- 3 files changed, 40 insertions(+), 31 deletions(-) diff --git a/api/config/v1/config.pb.go b/api/config/v1/config.pb.go index bb2f5e5..d31c997 100644 --- a/api/config/v1/config.pb.go +++ b/api/config/v1/config.pb.go @@ -905,10 +905,12 @@ type Nacos struct { Username string `protobuf:"bytes,5,opt,name=username,proto3" json:"username,omitempty"` // nacos config password Password string `protobuf:"bytes,6,opt,name=password,proto3" json:"password,omitempty"` + // the nacos server contextpath,default=/nacos,this is not required in 2.0 + ContextPath string `protobuf:"bytes,7,opt,name=context_path,json=contextPath,proto3" json:"context_path,omitempty"` // nacos config log dir - LogDir string `protobuf:"bytes,7,opt,name=log_dir,json=logDir,proto3" json:"log_dir,omitempty"` + LogDir string `protobuf:"bytes,8,opt,name=log_dir,json=logDir,proto3" json:"log_dir,omitempty"` // nacos config cache dir - CacheDir string `protobuf:"bytes,8,opt,name=cache_dir,json=cacheDir,proto3" json:"cache_dir,omitempty"` + CacheDir string `protobuf:"bytes,9,opt,name=cache_dir,json=cacheDir,proto3" json:"cache_dir,omitempty"` // nacos timeout(ms). default 5000 Timeout *durationpb.Duration `protobuf:"bytes,10,opt,name=timeout,proto3" json:"timeout,omitempty"` // nacos logger level. default info @@ -989,6 +991,13 @@ func (x *Nacos) GetPassword() string { return "" } +func (x *Nacos) GetContextPath() string { + if x != nil { + return x.ContextPath + } + return "" +} + func (x *Nacos) GetLogDir() string { if x != nil { return x.LogDir @@ -1216,7 +1225,7 @@ var file_config_v1_config_proto_rawDesc = []byte{ 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, - 0xb0, 0x02, 0x0a, 0x05, 0x4e, 0x61, 0x63, 0x6f, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, + 0xd3, 0x02, 0x0a, 0x05, 0x4e, 0x61, 0x63, 0x6f, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x17, 0x0a, 0x07, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x61, 0x74, 0x61, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, @@ -1226,24 +1235,26 @@ var file_config_v1_config_proto_rawDesc = []byte{ 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x6c, 0x6f, - 0x67, 0x5f, 0x64, 0x69, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x6f, 0x67, - 0x44, 0x69, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x64, 0x69, 0x72, - 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x61, 0x63, 0x68, 0x65, 0x44, 0x69, 0x72, - 0x12, 0x33, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x74, 0x69, - 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x6c, 0x6f, 0x67, 0x5f, 0x6c, 0x65, 0x76, - 0x65, 0x6c, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x6f, 0x67, 0x4c, 0x65, 0x76, - 0x65, 0x6c, 0x22, 0x50, 0x0a, 0x0a, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2e, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x07, 0x6f, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x29, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x6e, 0x65, 0x78, 0x74, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2f, 0x6e, 0x65, 0x78, - 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, + 0x6e, 0x74, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x50, 0x61, 0x74, 0x68, 0x12, 0x17, 0x0a, + 0x07, 0x6c, 0x6f, 0x67, 0x5f, 0x64, 0x69, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x6c, 0x6f, 0x67, 0x44, 0x69, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x61, 0x63, 0x68, 0x65, 0x5f, + 0x64, 0x69, 0x72, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x61, 0x63, 0x68, 0x65, + 0x44, 0x69, 0x72, 0x12, 0x33, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x0a, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x6c, 0x6f, 0x67, 0x5f, + 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x6f, 0x67, + 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x22, 0x50, 0x0a, 0x0a, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, + 0x61, 0x72, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2e, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x07, + 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x29, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6e, 0x65, 0x78, 0x74, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2f, + 0x6e, 0x65, 0x78, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, + 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/config/v1/config.proto b/api/config/v1/config.proto index cdb79b7..c20c727 100644 --- a/api/config/v1/config.proto +++ b/api/config/v1/config.proto @@ -103,10 +103,10 @@ message Registry { // Telemetry config message Telemetry { - bool disable = 1; // disable tracing + bool disable = 1; // disable tracing string exporter = 2; // tracing exporter, eg: otlphttp, otlpgrpc, stdout, zipkin, file, noop - string endpoint = 3; // tracing endpoint - double sampler = 4; // tracing sampler: 0-1, 1 means full sampling, 0 means no sampling + string endpoint = 3; // tracing endpoint + double sampler = 4; // tracing sampler: 0-1, 1 means full sampling, 0 means no sampling map headers = 5; // otlp headers string http_path = 6; // otlp http path } @@ -125,10 +125,12 @@ message Nacos { string username = 5; // nacos config password string password = 6; + // the nacos server contextpath,default=/nacos,this is not required in 2.0 + string context_path = 7; // nacos config log dir - string log_dir = 7; + string log_dir = 8; // nacos config cache dir - string cache_dir = 8; + string cache_dir = 9; // nacos timeout(ms). default 5000 google.protobuf.Duration timeout = 10; // nacos logger level. default info diff --git a/config/config.go b/config/config.go index c92041d..d7747f7 100644 --- a/config/config.go +++ b/config/config.go @@ -97,11 +97,7 @@ func (c *Config) buildNacosSource() ([]kConfig.Source, error) { if err != nil { return nil, err } - - serverConfigs = append(serverConfigs, constant.ServerConfig{ - IpAddr: host, - Port: p, - }) + serverConfigs = append(serverConfigs, *constant.NewServerConfig(host, p, constant.WithContextPath(cfg.ContextPath))) } var duration uint64 = 5000