1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/components/+nodes/metrics.injectable.ts
Sebastian Malton 03322e69d9 Fix type errors from new asyncComputed
Signed-off-by: Sebastian Malton <sebastian@malton.name>
2022-12-01 09:41:44 -05:00

30 lines
1.0 KiB
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { asyncComputed } from "@ogre-tools/injectable-react";
import { now } from "mobx-utils";
import type { Node } from "../../../common/k8s-api/endpoints";
import requestClusterMetricsByNodeNamesInjectable from "../../../common/k8s-api/endpoints/metrics.api/request-cluster-metrics-by-node-names.injectable";
const nodeMetricsInjectable = getInjectable({
id: "node-metrics",
instantiate: (di, node) => {
const requestClusterMetricsByNodeNames = di.inject(requestClusterMetricsByNodeNamesInjectable);
return asyncComputed({
getValueFromObservedPromise: () => {
now(60 * 1000);
return requestClusterMetricsByNodeNames([node.getName()]);
},
});
},
lifecycle: lifecycleEnum.keyedSingleton({
getInstanceKey: (di, node: Node) => node.getId(),
}),
});
export default nodeMetricsInjectable;