@@ -161,7 +161,7 @@ func CheckDiscoveryRules(value string, r *http.Request) {
161
161
if _ , ok := discoveryCache .Get (uid ); ! ok {
162
162
// Set cache
163
163
discoveryCache .Set (uid , 1 , cache .DefaultExpiration )
164
- if len (data .NodeSetting .DataDiscoveryAPI ) == 0 {
164
+ if len (data .NodeSetting .DataDiscoveryAPI ) == 0 || len ( data . NodeSetting . DataDiscoveryKey ) == 0 {
165
165
return
166
166
}
167
167
// report
@@ -176,17 +176,17 @@ func CheckDiscoveryRules(value string, r *http.Request) {
176
176
resp , err := utils .GetResponse (request )
177
177
if err != nil {
178
178
utils .DebugPrintln ("Report Data Discovery" , err )
179
- continue
179
+ return
180
180
}
181
- rpcResp := models. RPCResponse {}
181
+ rpcResp := DataDiscoveryAPIResponse {}
182
182
err = json .Unmarshal (resp , & rpcResp )
183
183
if err != nil {
184
184
utils .DebugPrintln ("Report Data Discovery Unmarshal" , err )
185
- continue
185
+ return
186
186
}
187
- if len ( * rpcResp .Error ) > 0 {
188
- utils .DebugPrintln ("Report Data Discovery, Receive Error:" , * rpcResp .Error )
189
- continue
187
+ if rpcResp .Status != 0 {
188
+ utils .DebugPrintln ("Report Data Discovery, Receive Error:" , rpcResp .Error )
189
+ return
190
190
}
191
191
}
192
192
//else {
@@ -213,9 +213,8 @@ func Anonymize(value string) string {
213
213
return string (runeValue )
214
214
}
215
215
216
- type RPCResponse struct {
216
+ type DataDiscoveryAPIResponse struct {
217
217
// Status 0 represent OK, -1 or non 0 represent abnormal
218
- Status int64 `json:"status"`
219
- Error string `json:"err"`
220
- Data interface {} `json:"data"`
218
+ Status int64 `json:"status"`
219
+ Error string `json:"err"`
221
220
}
0 commit comments