reafctor: pool

This commit is contained in:
meilin.huang
2025-05-22 23:29:50 +08:00
parent 142bbd265d
commit 778cb7f4de
50 changed files with 1146 additions and 874 deletions

View File

@@ -14,11 +14,19 @@ type MongoConn struct {
Cli *mongo.Client
}
func (mc *MongoConn) Close() {
/******************* pool.Conn impl *******************/
func (mc *MongoConn) Close() error {
if mc.Cli != nil {
if err := mc.Cli.Disconnect(context.Background()); err != nil {
logx.Errorf("关闭mongo实例[%s]连接失败: %s", mc.Id, err)
return err
}
mc.Cli = nil
}
return nil
}
func (mc *MongoConn) Ping() error {
return mc.Cli.Ping(context.Background(), nil)
}