refactor: 数据库meta使用注册方式,方便可插拔

This commit is contained in:
meilin.huang
2024-01-24 17:01:17 +08:00
parent bed95254d0
commit 7e9a381641
14 changed files with 55 additions and 99 deletions

View File

@@ -6,21 +6,14 @@ import (
"fmt"
"mayfly-go/internal/db/dbm/dbi"
"net"
"sync"
"github.com/go-sql-driver/mysql"
)
var (
meta dbi.Meta
once sync.Once
)
func GetMeta() dbi.Meta {
once.Do(func() {
meta = new(MysqlMeta)
})
return meta
func init() {
meta := new(MysqlMeta)
dbi.Register(dbi.DbTypeMysql, meta)
dbi.Register(dbi.DbTypeMariadb, meta)
}
type MysqlMeta struct {