Search: wrap data.Frame in a backend.DataResponse and return it directly when the index is not ready (#56611)

This commit is contained in:
Artur Wierzbicki 2022-10-10 22:05:16 +04:00 committed by GitHub
parent 25e89ba295
commit 1bbbe41a6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ import (
"errors"
"io"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana/pkg/api/response"
"github.com/grafana/grafana/pkg/api/routing"
@ -36,14 +37,12 @@ func (s *searchHTTPService) doQuery(c *models.ReqContext) response.Response {
"reason": searchReadinessCheckResp.Reason,
}).Inc()
bytes, err := (&data.Frame{
Name: "Loading",
}).MarshalJSON()
if err != nil {
return response.Error(500, "error marshalling response", err)
}
return response.JSON(200, bytes)
return response.JSON(200, &backend.DataResponse{
Frames: []*data.Frame{{
Name: "Loading",
}},
Error: nil,
})
}
body, err := io.ReadAll(c.Req.Body)