共用配置文件导入
This commit is contained in:
19
bin/main.go
19
bin/main.go
@@ -174,6 +174,15 @@ func (image *Image) GetSimilarImagesIdList(collection_name string) (ids []int64)
|
||||
|
||||
func main() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
||||
viper.SetConfigFile("./data/config.yaml")
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
log.Println("读取配置文件失败", err)
|
||||
}
|
||||
config := viper.GetViper()
|
||||
|
||||
models.InitConfig(config)
|
||||
|
||||
mysqlConnection.Init()
|
||||
milvusConnection.Init()
|
||||
err := milvusConnection.Client.LoadCollection(context.Background(), "default", false)
|
||||
@@ -183,7 +192,15 @@ func main() {
|
||||
}
|
||||
|
||||
// Schema
|
||||
schema, err := api.NewSchema()
|
||||
schema, err := api.NewSchema(api.Config{
|
||||
Mysql: api.ConfigMysql{
|
||||
Host: config.GetString("mysql.host"),
|
||||
Port: config.GetInt("mysql.port"),
|
||||
Database: config.GetString("mysql.database"),
|
||||
UserName: config.GetString("mysql.user"),
|
||||
Password: config.GetString("mysql.password"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("failed to create new schema, error: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user