Refactor Milvus connection initialization
This commit is contained in:
		@@ -2,8 +2,8 @@ package models
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"log"
 | 
			
		||||
	"strconv"
 | 
			
		||||
 | 
			
		||||
	"github.com/milvus-io/milvus-sdk-go/v2/client"
 | 
			
		||||
)
 | 
			
		||||
@@ -20,9 +20,9 @@ func (m *MilvusConnection) Init() (err error) {
 | 
			
		||||
	log.Println("Milvus connection init")
 | 
			
		||||
	host := Viper.Get("milvus.host").(string)
 | 
			
		||||
	port := Viper.Get("milvus.port").(int)
 | 
			
		||||
	address_of_milvus := host + ":" + strconv.Itoa(port)
 | 
			
		||||
	log.Println("Milvus address:", address_of_milvus)
 | 
			
		||||
	m.Client, err = client.NewGrpcClient(context.Background(), address_of_milvus)
 | 
			
		||||
	address := fmt.Sprintf("%s:%d", host, port)
 | 
			
		||||
	log.Println("Milvus address:", address)
 | 
			
		||||
	m.Client, err = client.NewGrpcClient(context.Background(), address)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Println("Milvus connection failed:", err)
 | 
			
		||||
		return
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user