File size: 787 Bytes
623fdec
11eaf27
 
 
623fdec
11eaf27
 
 
 
 
623fdec
 
 
11eaf27
 
 
623fdec
11eaf27
 
623fdec
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from pymilvus import connections
from pymilvus.exceptions import ConnectionConfigException

class MilvusClientSingleton:
    # ... (rest of the class code)

    def __init__(self, uri):
        if MilvusClientSingleton._instance is not None:
            raise Exception("This class is a singleton!")
        try:
            # Use connections.connect()
            connections.connect(uri=uri)
            self._instance = connections  # Store the connections object
            print(f"Successfully connected to Milvus at {uri}")
        except ConnectionConfigException as e:
            print(f"Error connecting to Milvus: {e}")
            raise

    def __getattr__(self, name):
        # Delegate attribute access to the default connection
        return getattr(connections, name)