Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build a pool of connections <> Check if the connection is dead to revive it. #270

Open
asennoussi opened this issue Jan 2, 2024 · 1 comment

Comments

@asennoussi
Copy link

asennoussi commented Jan 2, 2024

I'm trying to build a pool of connections to make sure Milvus uptime is always or almost always.
In my logic I have something like this:

return {
        getClient: async () => {
          // Simple round-robin client selection
          let client = pool[currentIndex];
          currentIndex = (currentIndex + 1) % poolSize;

          // Check if client is connected
          if (!client.isConnected()) {
            try {
              // Replace the disconnected client in the pool
              client = await createClient();
              pool[currentIndex] = client;
            } catch (error) {
              console.error('Error reconnecting to Milvus:', error);
              // Handle reconnection failure if needed
            }
          }

          return client;
        },```
        

But I don't know how to translate `isConnected()` 
Any guidance is highly appreciated. 
@shanghaikid
Copy link
Contributor

I've introduced a pool in the main branch.

But in your case, I suppose we need to watch Channel has been shut down event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants