Live: move centrifuge service to a web worker (#41090)

* Fix: make webpack pickup workers written in TS

* Add comlink to dependencies

* Temporary fix: copy paste `toDataQueryError` from @grafana/runtime to avoid web dependencies

* Implemented comlink-based centrifuge worker & worker proxy

* Temporary fix: implement comlink transferHandlers for subscriptions and streamingdataframes

* Move liveTimer filtering from CentrifugeService into GrafanaLiveService

* Switch from CentrifugeService to CentrifugeServiceWorkerProxy in GrafanaLive

* Naming fix

* Refactor: move liveTimer-based data filtering from GrafanaLiveService to CentrifugeServiceWorker

* observe dataStream on an async scheduler

* Fix: - Unsubscribe is now propagated from the main thread to the worker, - improve worker&workerProxy types

* Fix: Prettify types

* Fix: Add error & complete observers

* Docs: Add comment explaining the `subscriberTransferHandler`

* Fix: Replace `StreamingDataFrameHandler` with explicitly converting StreamingDataFrame to a DataFrameDTO

* Refactor: move liveTimer filtering to service.ts to make it easy to implement a `live-service-web-worker` feature flag

* Feat: add `live-service-web-worker` feature flag

* Fix: extract toDataQueryError.ts to a separate file within `@grafana-runtime` to avoid having a dependency from webworker to the whole package (@grafana-runtime/index.ts)

* Update public/app/features/dashboard/dashgrid/liveTimer.ts

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>

* Fix: fixed default import class in worker file

* Fix: cast worker as Endpoint

* Migrate from worker-loader to webpack native worker support v1 - broken prod build

* Fix: Use custom path in HtmlWebpackPlugin

* Fix: Loading workers from CDNs

* Fix: Avoid issues with jest ESM support by mocking `createWorker` files

* Fix: move the custom mockWorker rendering layout to `test/mocks`

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
Artur Wierzbicki
2021-11-09 21:05:01 +04:00
committed by GitHub
parent e2ed140de2
commit f45eb309ef
23 changed files with 387 additions and 92 deletions
+8 -13
View File
@@ -12355,6 +12355,13 @@ __metadata:
languageName: node
linkType: hard
"comlink@npm:4.3.1":
version: 4.3.1
resolution: "comlink@npm:4.3.1"
checksum: 557360a6558708c55aff74a25f834bfb9bfca8a42444682c4d5aead57681534a0206202be2a2760b4de124c3ba6d485b08978b6d5469cb3d26bf1438ee28a4f1
languageName: node
linkType: hard
"comma-separated-tokens@npm:^1.0.0":
version: 1.0.8
resolution: "comma-separated-tokens@npm:1.0.8"
@@ -17829,6 +17836,7 @@ __metadata:
centrifuge: 2.7.5
classnames: 2.2.6
clipboard: 2.0.4
comlink: 4.3.1
common-tags: ^1.8.0
copy-webpack-plugin: 9.0.1
core-js: 3.10.0
@@ -17994,7 +18002,6 @@ __metadata:
webpack-dev-server: 4.3.1
webpack-merge: 5.8.0
whatwg-fetch: 3.1.0
worker-loader: ^3.0.8
languageName: unknown
linkType: soft
@@ -33911,18 +33918,6 @@ __metadata:
languageName: node
linkType: hard
"worker-loader@npm:^3.0.8":
version: 3.0.8
resolution: "worker-loader@npm:3.0.8"
dependencies:
loader-utils: ^2.0.0
schema-utils: ^3.0.0
peerDependencies:
webpack: ^4.0.0 || ^5.0.0
checksum: 84f4a7eeb2a1d8b9704425837e017c91eedfae67ac89e0b866a2dcf283323c1dcabe0258196278b7d5fd0041392da895c8a0c59ddf3a94f1b2e003df68ddfec3
languageName: node
linkType: hard
"worker-rpc@npm:^0.1.0":
version: 0.1.1
resolution: "worker-rpc@npm:0.1.1"