mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Live: broadcast first event immediately (#34310)
This commit is contained in:
parent
25485100b0
commit
18954aaa7b
@ -214,23 +214,11 @@ export class CentrifugeSrv implements GrafanaLiveSrv {
|
|||||||
|
|
||||||
return new Observable<DataQueryResponse>((subscriber) => {
|
return new Observable<DataQueryResponse>((subscriber) => {
|
||||||
const channel = this.getChannel(options.addr);
|
const channel = this.getChannel(options.addr);
|
||||||
|
const key = options.key ?? `xstr/${streamCounter++}`;
|
||||||
let data: StreamingDataFrame | undefined = undefined;
|
let data: StreamingDataFrame | undefined = undefined;
|
||||||
let filtered: DataFrame | undefined = undefined;
|
let filtered: DataFrame | undefined = undefined;
|
||||||
let state = LoadingState.Loading;
|
let state = LoadingState.Streaming;
|
||||||
let { key } = options;
|
|
||||||
let last = perf.last;
|
let last = perf.last;
|
||||||
if (options.frame) {
|
|
||||||
const msg = dataFrameToJSON(options.frame);
|
|
||||||
data = new StreamingDataFrame(msg, options.buffer);
|
|
||||||
state = LoadingState.Streaming;
|
|
||||||
}
|
|
||||||
if (channel.lastMessageWithSchema && !data) {
|
|
||||||
data = new StreamingDataFrame(channel.lastMessageWithSchema, options.buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!key) {
|
|
||||||
key = `xstr/${streamCounter++}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const process = (msg: DataFrameJSON) => {
|
const process = (msg: DataFrameJSON) => {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
@ -262,6 +250,12 @@ export class CentrifugeSrv implements GrafanaLiveSrv {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (options.frame) {
|
||||||
|
process(dataFrameToJSON(options.frame));
|
||||||
|
} else if (channel.lastMessageWithSchema) {
|
||||||
|
process(channel.lastMessageWithSchema);
|
||||||
|
}
|
||||||
|
|
||||||
const sub = channel.getStream().subscribe({
|
const sub = channel.getStream().subscribe({
|
||||||
error: (err: any) => {
|
error: (err: any) => {
|
||||||
console.log('LiveQuery [error]', { err }, options.addr);
|
console.log('LiveQuery [error]', { err }, options.addr);
|
||||||
|
Loading…
Reference in New Issue
Block a user