mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Move disconnecting cluster connections to own runnable
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
980b054fad
commit
1581da458d
5 files changed
+24
-46
No files matched your search
@@ -226,14 +226,6 @@ export class ClusterManager {
|
||||
)),
|
||||
);
|
||||
};
|
||||
|
||||
stop() {
|
||||
for (const cluster of this.dependencies.clusters.get()) {
|
||||
this.dependencies
|
||||
.getClusterConnection(cluster)
|
||||
.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function catalogEntityFromCluster(cluster: Cluster) {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import clustersInjectable from "../../features/cluster/storage/common/clusters.injectable";
|
||||
import { onQuitOfBackEndInjectionToken } from "../start-main-application/runnable-tokens/phases";
|
||||
import clusterConnectionInjectable from "./cluster-connection.injectable";
|
||||
|
||||
const stopAllClusterConnectionsOnQuitInjectable = getInjectable({
|
||||
id: "stop-all-cluster-connections-on-quit",
|
||||
instantiate: (di) => ({
|
||||
run: () => {
|
||||
const clusters = di.inject(clustersInjectable).get();
|
||||
|
||||
for (const cluster of clusters) {
|
||||
di.inject(clusterConnectionInjectable, cluster).disconnect();
|
||||
}
|
||||
},
|
||||
}),
|
||||
injectionToken: onQuitOfBackEndInjectionToken,
|
||||
});
|
||||
|
||||
export default stopAllClusterConnectionsOnQuitInjectable;
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import clusterManagerInjectable from "../../cluster/manager.injectable";
|
||||
import { afterQuitOfFrontEndInjectionToken } from "../runnable-tokens/phases";
|
||||
|
||||
const stopClusterManagerInjectable = getInjectable({
|
||||
id: "stop-cluster-manager",
|
||||
|
||||
instantiate: (di) => ({
|
||||
run: () => {
|
||||
const clusterManager = di.inject(clusterManagerInjectable);
|
||||
|
||||
clusterManager.stop();
|
||||
|
||||
return undefined;
|
||||
},
|
||||
}),
|
||||
|
||||
injectionToken: afterQuitOfFrontEndInjectionToken,
|
||||
});
|
||||
|
||||
export default stopClusterManagerInjectable;
|
||||
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import forceAppExitInjectable from "./electron-app/features/force-app-exit.injectable";
|
||||
import clusterManagerInjectable from "./cluster/manager.injectable";
|
||||
import loggerInjectable from "../common/logger.injectable";
|
||||
import emitAppEventInjectable from "../common/app-event-bus/emit-event.injectable";
|
||||
|
||||
@@ -13,13 +12,11 @@ const stopServicesAndExitAppInjectable = getInjectable({
|
||||
|
||||
instantiate: (di) => {
|
||||
const forceAppExit = di.inject(forceAppExitInjectable);
|
||||
const clusterManager = di.inject(clusterManagerInjectable);
|
||||
const logger = di.inject(loggerInjectable);
|
||||
const emitAppEvent = di.inject(emitAppEventInjectable);
|
||||
|
||||
return async () => {
|
||||
emitAppEvent({ name: "service", action: "close" });
|
||||
clusterManager.stop();
|
||||
logger.info("SERVICE:QUIT");
|
||||
setTimeout(forceAppExit, 1000);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user