mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Make DetectoryRegistry a Singleton and initialize in a function (#3538)
This commit is contained in:
1 parent
9a8616f05e
commit
574aea40b4
5 files changed
+46
-18
No files matched your search
@@ -21,19 +21,17 @@
|
||||
|
||||
import { observable } from "mobx";
|
||||
import type { ClusterMetadata } from "../../common/cluster-types";
|
||||
import { Singleton } from "../../common/utils";
|
||||
import type { Cluster } from "../cluster";
|
||||
import type { BaseClusterDetector, ClusterDetectionResult } from "./base-cluster-detector";
|
||||
import { ClusterIdDetector } from "./cluster-id-detector";
|
||||
import { DistributionDetector } from "./distribution-detector";
|
||||
import { LastSeenDetector } from "./last-seen-detector";
|
||||
import { NodesCountDetector } from "./nodes-count-detector";
|
||||
import { VersionDetector } from "./version-detector";
|
||||
|
||||
export class DetectorRegistry {
|
||||
export class DetectorRegistry extends Singleton {
|
||||
registry = observable.array<typeof BaseClusterDetector>([], { deep: false });
|
||||
|
||||
add(detectorClass: typeof BaseClusterDetector) {
|
||||
add(detectorClass: typeof BaseClusterDetector): this {
|
||||
this.registry.push(detectorClass);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
async detectForCluster(cluster: Cluster): Promise<ClusterMetadata> {
|
||||
@@ -63,10 +61,3 @@ export class DetectorRegistry {
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
|
||||
export const detectorRegistry = new DetectorRegistry();
|
||||
detectorRegistry.add(ClusterIdDetector);
|
||||
detectorRegistry.add(LastSeenDetector);
|
||||
detectorRegistry.add(VersionDetector);
|
||||
detectorRegistry.add(DistributionDetector);
|
||||
detectorRegistry.add(NodesCountDetector);
|
||||
Reference in new issue
Block a user