Live: use latest changes in Go SDK to deal with streaming frames (#34668) (#34678)

(cherry picked from commit 063e1b5ff5)

Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2021-05-25 20:16:54 +02:00
committed by GitHub
co-authored by Alexander Emelin
parent ef05f687ca
commit e2b6820d42
15 changed files with 84 additions and 101 deletions
+4 -2
View File
@@ -106,11 +106,12 @@ func (s *ManagedStream) ListChannels(orgID int64, prefix string) []util.DynMap {
// unstableSchema flag can be set to disable schema caching for a path.
func (s *ManagedStream) Push(orgID int64, path string, frame *data.Frame, unstableSchema bool) error {
// Keep schema + data for last packet.
frameJSON, err := data.FrameToJSON(frame, true, true)
frameJSONWrapper, err := data.FrameToJSON(frame)
if err != nil {
logger.Error("Error marshaling frame with Schema", "error", err)
return err
}
frameJSON := frameJSONWrapper.Bytes(data.IncludeAll)
if !unstableSchema {
// If schema is stable we can safely cache it, and only send values if
@@ -128,11 +129,12 @@ func (s *ManagedStream) Push(orgID int64, path string, frame *data.Frame, unstab
// frame to keep Schema JSON and Values JSON in frame object
// to avoid encoding twice.
if exists {
frameJSON, err = data.FrameToJSON(frame, false, true)
frameJSONWrapper, err = data.FrameToJSON(frame)
if err != nil {
logger.Error("Error marshaling Frame to JSON", "error", err)
return err
}
frameJSON = frameJSONWrapper.Bytes(data.IncludeDataOnly)
}
} else {
// For unstable schema we always need to send everything to a connection.