Gorm Ping Db Shards



我希望在我的应用程序中管理数据库分片的映射。使用 GORM 时,主动 PING 所有分片以验证连接的过程是什么。

我正在寻找类似的东西:

import (
"github.com.jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"
)
for _, shard := range shardMap {
if err := shard.Ping() {
//DO SOMETHING
}
}

问题是碎片。Ping(( 不是一回事。我觉得我在某个地方错过了一个进口。

作为后续,语法是

shard.DB().Ping()    

最新更新