Browse Source

ignore listDatabase error if the feature is not avaliable

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
ryjiang 1 year ago
parent
commit
9f391e4982
1 changed files with 12 additions and 3 deletions
  1. 12 3
      server/src/milvus/milvus.service.ts

+ 12 - 3
server/src/milvus/milvus.service.ts

@@ -11,10 +11,15 @@ import { connectivityState } from '@grpc/grpc-js';
 import { DatabasesService } from '../database/databases.service';
 import { DatabasesService } from '../database/databases.service';
 
 
 export class MilvusService {
 export class MilvusService {
+  private databaseService: DatabasesService;
   // Share with all instances, so activeAddress is static
   // Share with all instances, so activeAddress is static
   static activeAddress: string;
   static activeAddress: string;
   static activeMilvusClient: MilvusClient;
   static activeMilvusClient: MilvusClient;
 
 
+  constructor() {
+    this.databaseService = new DatabasesService(this);
+  }
+
   get sdkInfo() {
   get sdkInfo() {
     return MilvusClient.sdkInfo;
     return MilvusClient.sdkInfo;
   }
   }
@@ -88,12 +93,16 @@ export class MilvusService {
       cache.set(address, milvusClient);
       cache.set(address, milvusClient);
 
 
       // Create a new database service and check if the specified database exists
       // Create a new database service and check if the specified database exists
-      const databaseService = new DatabasesService(this);
-      const hasDatabase = await databaseService.hasDatabase(database);
+      let hasDatabase = false;
+      try {
+        hasDatabase = await this.databaseService.hasDatabase(database);
+      } catch (_) {
+        // ignore error
+      }
 
 
       // if database exists, use this db
       // if database exists, use this db
       if (hasDatabase) {
       if (hasDatabase) {
-        await databaseService.use(database);
+        await this.databaseService.use(database);
       }
       }
 
 
       // Return the address and the database (if it exists, otherwise return 'default')
       // Return the address and the database (if it exists, otherwise return 'default')