diff --git a/client/src/context/Auth.tsx b/client/src/context/Auth.tsx index f296e712..a83910f5 100644 --- a/client/src/context/Auth.tsx +++ b/client/src/context/Auth.tsx @@ -17,6 +17,7 @@ export const authContext = createContext({ address: '', token: '', database: '', + checkHealth: true, }, setAuthReq: () => {}, isManaged: false, @@ -38,6 +39,7 @@ export const AuthProvider = (props: { children: React.ReactNode }) => { address: MILVUS_URL, token: '', database: MILVUS_DATABASE, + checkHealth: true, }) ); diff --git a/client/src/i18n/cn/common.ts b/client/src/i18n/cn/common.ts index a7cff22b..4991d08b 100644 --- a/client/src/i18n/cn/common.ts +++ b/client/src/i18n/cn/common.ts @@ -16,6 +16,7 @@ const commonTrans = { prometheusInstance: 'Prometheus实例', prometheusNamespace: 'Prometheus命名空间', connectionTip: '支持自托管Milvus或Zilliz云专用集群。', + checkHealth: '检查健康状态', }, status: { loaded: '已加载', diff --git a/client/src/i18n/en/common.ts b/client/src/i18n/en/common.ts index 865941c2..4968e404 100644 --- a/client/src/i18n/en/common.ts +++ b/client/src/i18n/en/common.ts @@ -17,6 +17,7 @@ const commonTrans = { prometheusNamespace: 'Prometheus Namespace', connectionTip: 'Self-hosted Milvus or Zilliz Cloud Dedicated cluster are supported.', + checkHealth: 'Check Health', }, status: { loaded: 'loaded', diff --git a/client/src/pages/connect/AuthForm.tsx b/client/src/pages/connect/AuthForm.tsx index 54a93adc..44ebb8f2 100644 --- a/client/src/pages/connect/AuthForm.tsx +++ b/client/src/pages/connect/AuthForm.tsx @@ -1,5 +1,5 @@ import React, { useContext, useEffect, useMemo, useState } from 'react'; -import { Typography, Menu } from '@mui/material'; +import { Typography, Menu, Checkbox } from '@mui/material'; import { useTranslation } from 'react-i18next'; import CustomButton from '@/components/customButton/CustomButton'; import CustomInput from '@/components/customInput/CustomInput'; @@ -30,6 +30,7 @@ const DEFAULT_CONNECTION = { token: '', username: '', password: '', + checkHealth: true, time: -1, }; @@ -68,7 +69,13 @@ export const AuthForm = () => { // UI handlers // handle input change const handleInputChange = ( - key: 'address' | 'username' | 'password' | 'database' | 'token', + key: + | 'address' + | 'username' + | 'password' + | 'database' + | 'token' + | 'checkHealth', value: string | boolean ) => { // set database to default if empty @@ -128,6 +135,7 @@ export const AuthForm = () => { password: authReq.password, token: authReq.token, time: Date.now(), + checkHealth: authReq.checkHealth, }, ]; @@ -363,6 +371,19 @@ export const AuthForm = () => { {btnTrans(isConnecting ? 'connecting' : 'connect')} + +
+ +
({ width: '100%', justifyContent: 'flex-start', }, + checkHealth: { + display: 'flex', + alignItems: 'center', + marginTop: 4, + '& .MuiCheckbox-root': { + margin: 0, + padding: '8px 4px 8px 0', + }, + '& span': { + cursor: 'pointer', + fontSize: 12, + fontStyle: 'italic', + }, + }, star: { position: 'absolute', top: -48, diff --git a/server/src/milvus/milvus.controller.ts b/server/src/milvus/milvus.controller.ts index 5b4b4a22..afa93b8a 100644 --- a/server/src/milvus/milvus.controller.ts +++ b/server/src/milvus/milvus.controller.ts @@ -41,7 +41,8 @@ export class MilvusController { } async connectMilvus(req: Request, res: Response, next: NextFunction) { - const { address, username, password, database, token } = req.body; + const { address, username, password, database, token, checkHealth } = + req.body; try { const result = await this.milvusService.connectMilvus({ address, @@ -49,6 +50,7 @@ export class MilvusController { username, password, database, + checkHealth, }); res.send(result); diff --git a/server/src/milvus/milvus.service.ts b/server/src/milvus/milvus.service.ts index 39b067df..63cb1b3d 100644 --- a/server/src/milvus/milvus.service.ts +++ b/server/src/milvus/milvus.service.ts @@ -26,7 +26,7 @@ export class MilvusService { async connectMilvus(data: AuthReq): Promise { // Destructure the data object to get the connection details - const { address, token, username, password, database } = data; + const { address, token, username, password, database, checkHealth } = data; // Format the address to remove the http prefix const milvusAddress = MilvusService.formatAddress(address); @@ -71,12 +71,14 @@ export class MilvusService { } // Check the health of the Milvus server - const res = await milvusClient.checkHealth(); + if (checkHealth) { + const res = await milvusClient.checkHealth(); - // If the server is not healthy, throw an error - if (!res.isHealthy) { - clientCache.delete(milvusClient.clientId); - throw new Error('Milvus is not ready yet.'); + // If the server is not healthy, throw an error + if (!res.isHealthy) { + clientCache.delete(milvusClient.clientId); + throw new Error('Milvus is not ready yet.'); + } } // database diff --git a/server/src/types/index.ts b/server/src/types/index.ts index 3901186b..c2a476a0 100644 --- a/server/src/types/index.ts +++ b/server/src/types/index.ts @@ -16,6 +16,7 @@ export type AuthReq = { address: string; token: string; database: string; + checkHealth: boolean; }; export type AuthObject = {