Skip to content

Commit

Permalink
Cleanup onNetworkOffline/Online impls within ClusterManager
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Malton <sebastian@malton.name>
  • Loading branch information
Nokel81 committed Jan 17, 2023
1 parent e066ab0 commit 1b2d306
Showing 1 changed file with 25 additions and 31 deletions.
56 changes: 25 additions & 31 deletions src/main/cluster/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,41 +235,35 @@ export class ClusterManager {
}
}

protected onNetworkOffline = () => {
protected onNetworkOffline = async () => {
this.dependencies.logger.info(`${logPrefix} network is offline`);
this.dependencies.store.clustersList.forEach((cluster) => {
if (!cluster.disconnected) {
cluster.online = false;
cluster.accessible = false;

void (async () => {
try {
await this.dependencies
.getClusterConnection(cluster)
.refreshConnectionStatus();
} catch {
// ignore
}
})();
}
});

await Promise.allSettled(
this.dependencies.store.clustersList
.filter(cluster => !cluster.disconnected)
.map(async (cluster) => {
cluster.online = false;
cluster.accessible = false;

await this.dependencies
.getClusterConnection(cluster)
.refreshConnectionStatus();
}),
);
};

protected onNetworkOnline = () => {
protected onNetworkOnline = async () => {
this.dependencies.logger.info(`${logPrefix} network is online`);
this.dependencies.store.clustersList.forEach((cluster) => {
if (!cluster.disconnected) {
void (async () => {
try {
await this.dependencies
.getClusterConnection(cluster)
.refreshConnectionStatus();
} catch {
// ignore
}
})();
}
});

await Promise.allSettled(
this.dependencies.store.clustersList
.filter(cluster => !cluster.disconnected)
.map((cluster) => (
this.dependencies
.getClusterConnection(cluster)
.refreshConnectionStatus()
)),
);
};

stop() {
Expand Down

0 comments on commit 1b2d306

Please sign in to comment.