Skip to content

Commit

Permalink
Recursion to ensure that collection exists (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leslie-Wong-H authored Apr 25, 2023
2 parents d9190cd + 6ce3ecd commit d69ef93
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,21 @@ const initializeMilvusCollection = async () => {
],
};

await milvusClient.collectionManager.releaseCollection({ collection_name: "shotit" });

await milvusClient.collectionManager.createCollection(params);
const fallBack = async () => {
try {
await milvusClient.collectionManager.releaseCollection({ collection_name: "shotit" });
await milvusClient.collectionManager.createCollection(params);
console.log('collection_name: "shotit" ensured');
milvusClient.closeConnection();
} catch (error) {
console.log(error);
console.log("initializeMilvusCollection reconnecting in 3 seconds");
await new Promise((resolve) => setTimeout(resolve, 1000 * 3));
await fallBack();
}
};

milvusClient.closeConnection();
await fallBack();
};

/**
Expand Down

0 comments on commit d69ef93

Please sign in to comment.