mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 01:23:32 -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) => {
|
||||
const channel = this.getChannel(options.addr);
|
||||
const key = options.key ?? `xstr/${streamCounter++}`;
|
||||
let data: StreamingDataFrame | undefined = undefined;
|
||||
let filtered: DataFrame | undefined = undefined;
|
||||
let state = LoadingState.Loading;
|
||||
let { key } = options;
|
||||
let state = LoadingState.Streaming;
|
||||
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) => {
|
||||
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({
|
||||
error: (err: any) => {
|
||||
console.log('LiveQuery [error]', { err }, options.addr);
|
||||
|
Loading…
Reference in New Issue
Block a user