mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
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() {}
|
|
}
|