The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/live/centrifuge/service.worker.ts

60 lines
1.5 KiB

import './transferHandlers';
import * as comlink from 'comlink';
import { LiveChannelAddress } from '@grafana/data';
import { LiveDataStreamOptions, LiveQueryDataOptions } from '@grafana/runtime';
import { remoteObservableAsObservable } from './remoteObservable';
import { CentrifugeService, CentrifugeSrvDeps } from './service';
let centrifuge: CentrifugeService;
const initialize = (
deps: CentrifugeSrvDeps,
remoteDataStreamSubscriberReadiness: comlink.RemoteObject<
CentrifugeSrvDeps['dataStreamSubscriberReadiness'] & comlink.ProxyMarked
>
) => {
centrifuge = new CentrifugeService({
...deps,
dataStreamSubscriberReadiness: remoteObservableAsObservable(remoteDataStreamSubscriberReadiness),
});
};
const getConnectionState = () => {
return comlink.proxy(centrifuge.getConnectionState());
};
const getDataStream = (options: LiveDataStreamOptions) => {
return comlink.proxy(centrifuge.getDataStream(options));
};
const getQueryData = async (options: LiveQueryDataOptions) => {
return await centrifuge.getQueryData(options);
};
const getStream = (address: LiveChannelAddress) => {
return comlink.proxy(centrifuge.getStream(address));
};
const getPresence = async (address: LiveChannelAddress) => {
return await centrifuge.getPresence(address);
};
const workObj = {
initialize,
getConnectionState,
getDataStream,
getStream,
getQueryData,
getPresence,
};
export type RemoteCentrifugeService = typeof workObj;
comlink.expose(workObj);
export default class {
constructor() {}
}