Live: Simplify live interface (#33196)

This commit is contained in:
Ryan McKinley
2021-04-23 23:21:38 +02:00
committed by GitHub
parent 1dd9e9b184
commit 693915de35
21 changed files with 405 additions and 382 deletions
@@ -13,9 +13,8 @@ import {
} from '@grafana/data';
import { merge, Observable, of } from 'rxjs';
import { catchError, switchMap } from 'rxjs/operators';
import { getBackendSrv, getDataSourceSrv } from '../services';
import { getBackendSrv, getDataSourceSrv, getGrafanaLiveSrv } from '../services';
import { BackendDataSourceResponse, toDataQueryResponse } from './queryResponse';
import { getLiveDataStream } from './liveQuery';
const ExpressionDatasourceID = '__expr__';
@@ -223,6 +222,11 @@ export function toStreamingDataResponse(
request: DataQueryRequest,
rsp: DataQueryResponse
): Observable<DataQueryResponse> {
const live = getGrafanaLiveSrv();
if (!live) {
return of(rsp); // add warning?
}
const buffer: StreamingFrameOptions = {
maxLength: request.maxDataPoints ?? 500,
};
@@ -238,7 +242,7 @@ export function toStreamingDataResponse(
const addr = parseLiveChannelAddress(frame.meta?.channel);
if (addr) {
streams.push(
getLiveDataStream({
live.getDataStream({
addr,
buffer,
frame: frame as DataFrame,