@@ -33,7 +33,7 @@ type NacosClientPropsConfigSource struct {
33
33
//
34
34
name string
35
35
lastCt uint32
36
- ClientConfig constant.ClientConfig
36
+ ClientConfig * constant.ClientConfig
37
37
ServerConfigs []constant.ServerConfig
38
38
Client config_client.IConfigClient
39
39
}
@@ -45,15 +45,16 @@ func NewNacosClientPropsConfigSource(address, group, dataId, tenant string) *Nac
45
45
s .DataId = dataId
46
46
s .Group = group
47
47
s .Tenant = tenant
48
- s .ClientConfig = constant.ClientConfig {
49
- TimeoutMs : 10 * 1000 , //http请求超时时间,单位毫秒
50
- ListenInterval : 30 * 1000 , //监听间隔时间,单位毫秒(仅在ConfigClient中有效)
51
- BeatInterval : 5 * 1000 , //心跳间隔时间,单位毫秒(仅在ServiceClient中有效)
52
- CacheDir : "./data/nacos/cache" , //缓存目录
53
- LogDir : "./data/nacos/log" , //日志目录
54
- UpdateThreadNum : 20 , //更新服务的线程数
55
- NotLoadCacheAtStart : true , //在启动时不读取本地缓存数据,true--不读取,false--读取
56
- UpdateCacheWhenEmpty : true , //当服务列表为空时是否更新本地缓存,true--更新,false--不更新
48
+ s .ClientConfig = & constant.ClientConfig {
49
+ TimeoutMs : 10 * 1000 , //请求Nacos服务端的超时时间,默认是10000ms
50
+ BeatInterval : 5 * 1000 , //心跳间隔时间,单位毫秒(仅在ServiceClient中有效)
51
+ CacheDir : "./nacos/cache" , //缓存目录
52
+ LogDir : "./nacos/log" , //日志目录
53
+ UpdateThreadNum : 20 , //更新服务的线程数
54
+ NotLoadCacheAtStart : true , //在启动时不读取本地缓存数据,true--不读取,false--读取
55
+ UpdateCacheWhenEmpty : false , //当服务列表为空时是否更新本地缓存,true--更新,false--不更新,当service返回的实例列表为空时,不更新缓存,用于推空保护
56
+ RotateTime : "1h" , // 日志轮转周期,比如:30m, 1h, 24h, 默认是24h
57
+ MaxAge : 3 , // 日志最大文件数,默认3
57
58
}
58
59
if len (tenant ) > 0 {
59
60
s .ClientConfig .NamespaceId = tenant
@@ -85,7 +86,7 @@ func NewNacosClientPropsConfigSource(address, group, dataId, tenant string) *Nac
85
86
var err error
86
87
s .Client , err = clients .CreateConfigClient (map [string ]interface {}{
87
88
constant .KEY_SERVER_CONFIGS : s .ServerConfigs ,
88
- constant .KEY_CLIENT_CONFIG : s .ClientConfig ,
89
+ constant .KEY_CLIENT_CONFIG : * s .ClientConfig ,
89
90
})
90
91
if err != nil {
91
92
log .Panic ("error create ConfigClient: " , err )
@@ -116,11 +117,11 @@ func (s *NacosClientPropsConfigSource) watchContext() {
116
117
DataId : "dataId" ,
117
118
Group : "group" ,
118
119
}
119
- if len (s .AppName ) > 0 {
120
- cp .AppName = s .AppName
121
- }
120
+ // if len(s.AppName) > 0 {
121
+ // cp.AppName = s.AppName
122
+ // }
122
123
cp .OnChange = func (namespace , group , dataId , data string ) {
123
- s .parseAndregisterProps ([]byte (data ))
124
+ s .parseAndRegisterProps ([]byte (data ))
124
125
log .Info ("changed config:" , namespace , group , dataId )
125
126
}
126
127
s .Client .ListenConfig (cp )
@@ -137,11 +138,11 @@ func (s *NacosClientPropsConfigSource) findProperties() {
137
138
log .Error (err )
138
139
return
139
140
}
140
- s .parseAndregisterProps (data )
141
+ s .parseAndRegisterProps (data )
141
142
142
143
}
143
144
144
- func (s * NacosClientPropsConfigSource ) parseAndregisterProps (data []byte ) {
145
+ func (s * NacosClientPropsConfigSource ) parseAndRegisterProps (data []byte ) {
145
146
sep := s .LineSeparator
146
147
if sep == "" {
147
148
sep = NACOS_LINE_SEPARATOR
@@ -179,9 +180,9 @@ func (h *NacosClientPropsConfigSource) get() (body []byte, err error) {
179
180
DataId : "dataId" ,
180
181
Group : "group" ,
181
182
}
182
- if len (h .AppName ) > 0 {
183
- cp .AppName = h .AppName
184
- }
183
+ // if len(h.AppName) > 0 {
184
+ // cp.AppName = h.AppName
185
+ // }
185
186
content , err := h .Client .GetConfig (cp )
186
187
if err != nil {
187
188
log .Error (err )
0 commit comments