Handle ds init errors

This commit is contained in:
Alexander Zobnin
2020-06-01 18:38:50 +03:00
parent df12c0443d
commit 3e379b01df
3 changed files with 19 additions and 3 deletions

View File

@@ -29,14 +29,14 @@ func (ds *ZabbixDatasourceInstance) ZabbixQuery(ctx context.Context, apiReq *Zab
cachedResult, queryExistInCache := ds.queryCache.Get(requestHash)
if !queryExistInCache {
resultJson, err = ds.ZabbixRequest(ctx, apiReq.Method, apiReq.Params)
if err != nil {
return nil, err
}
if _, ok := NotCachedMethods[apiReq.Method]; !ok {
ds.logger.Debug("Write result to cache", "method", apiReq.Method)
ds.queryCache.Set(requestHash, resultJson)
}
if err != nil {
return nil, err
}
} else {
var ok bool
resultJson, ok = cachedResult.(*simplejson.Json)