Skip to content

Commit f45b22f

Browse files
committed
fix: format
1 parent 24298ed commit f45b22f

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

src/tools/atlas/metadata/connectCluster.ts

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,18 @@ export class ConnectClusterTool extends AtlasToolBase {
2121
clusterName: z.string().describe("Atlas cluster name"),
2222
};
2323

24-
private async queryConnection(projectId: string, clusterName: string) : Promise<"connected" | "disconnected" | "connecting" | "connected-to-other-cluster"> {
24+
private async queryConnection(
25+
projectId: string,
26+
clusterName: string
27+
): Promise<"connected" | "disconnected" | "connecting" | "connected-to-other-cluster"> {
2528
if (!this.session.connectedAtlasCluster) {
2629
return "disconnected";
2730
}
2831

29-
if (this.session.connectedAtlasCluster.projectId !== projectId || this.session.connectedAtlasCluster.clusterName !== clusterName) {
32+
if (
33+
this.session.connectedAtlasCluster.projectId !== projectId ||
34+
this.session.connectedAtlasCluster.clusterName !== clusterName
35+
) {
3036
return "connected-to-other-cluster";
3137
}
3238

@@ -40,7 +46,7 @@ export class ConnectClusterTool extends AtlasToolBase {
4046
return "connected";
4147
}
4248

43-
private async prepareClusterConnection(projectId: string, clusterName: string) : Promise<string> {
49+
private async prepareClusterConnection(projectId: string, clusterName: string): Promise<string> {
4450
await this.session.disconnect();
4551

4652
const cluster = await inspectCluster(this.session.apiClient, projectId, clusterName);
@@ -109,7 +115,8 @@ export class ConnectClusterTool extends AtlasToolBase {
109115
private async connectToCluster(connectionString: string): Promise<void> {
110116
let lastError: Error | undefined = undefined;
111117

112-
for (let i = 0; i < 600; i++) { // try for 5 minutes
118+
for (let i = 0; i < 600; i++) {
119+
// try for 5 minutes
113120
try {
114121
await this.session.connectToMongoDB(connectionString, this.config.connectOptions);
115122
lastError = undefined;
@@ -128,29 +135,31 @@ export class ConnectClusterTool extends AtlasToolBase {
128135
await sleep(500); // wait for 500ms before retrying
129136
}
130137
}
131-
138+
132139
if (lastError) {
133-
void this.session.apiClient.deleteDatabaseUser({
134-
params: {
135-
path: {
136-
groupId: this.session.connectedAtlasCluster?.projectId || "",
137-
username: this.session.connectedAtlasCluster?.username || "",
138-
databaseName: "admin",
140+
void this.session.apiClient
141+
.deleteDatabaseUser({
142+
params: {
143+
path: {
144+
groupId: this.session.connectedAtlasCluster?.projectId || "",
145+
username: this.session.connectedAtlasCluster?.username || "",
146+
databaseName: "admin",
147+
},
139148
},
140-
},
141-
}).catch((err: unknown) => {
142-
const error = err instanceof Error ? err : new Error(String(err));
143-
logger.debug(
144-
LogId.atlasConnectFailure,
145-
"atlas-connect-cluster",
146-
`error deleting database user: ${error.message}`
147-
);
148-
});
149+
})
150+
.catch((err: unknown) => {
151+
const error = err instanceof Error ? err : new Error(String(err));
152+
logger.debug(
153+
LogId.atlasConnectFailure,
154+
"atlas-connect-cluster",
155+
`error deleting database user: ${error.message}`
156+
);
157+
});
149158
this.session.connectedAtlasCluster = undefined;
150159
throw lastError;
151160
}
152161
}
153-
162+
154163
protected async execute({ projectId, clusterName }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
155164
try {
156165
const state = await this.queryConnection(projectId, clusterName);

0 commit comments

Comments
 (0)