feat: 支持db_path, 适配 sqlite3 的数据库文件
This commit is contained in:
@@ -47,10 +47,6 @@ type wrapperClient struct {
|
||||
}
|
||||
|
||||
// AddWithConfigFile 使用文件生成新的客户端,文件名去掉后缀作为flag
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 19:19 2022/6/5
|
||||
func (c *wrapperClient) AddWithConfigFile(cfgFilePath string, logInstance *zap.Logger, extraFieldList []string) error {
|
||||
var (
|
||||
err error
|
||||
@@ -68,10 +64,6 @@ func (c *wrapperClient) AddWithConfigFile(cfgFilePath string, logInstance *zap.L
|
||||
}
|
||||
|
||||
// AddWithConfig ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 20:41 2023/4/18
|
||||
func (c *wrapperClient) AddWithConfig(flag string, logInstance *zap.Logger, databaseConfig *define.Database, extraFieldList []string) error {
|
||||
dbClient := &DBClient{
|
||||
DbFlag: flag,
|
||||
@@ -90,10 +82,6 @@ func (c *wrapperClient) AddWithConfig(flag string, logInstance *zap.Logger, data
|
||||
}
|
||||
|
||||
// BatchAddWithConfigDir 自动读取目录下配置文件, 生成客户端
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 19:19 2022/6/5
|
||||
func (c *wrapperClient) BatchAddWithConfigDir(cfgDir string, logInstance *zap.Logger, extraFieldList []string) error {
|
||||
filepathNames, _ := filepath.Glob(filepath.Join(cfgDir, "*"))
|
||||
for i := range filepathNames {
|
||||
@@ -105,10 +93,6 @@ func (c *wrapperClient) BatchAddWithConfigDir(cfgDir string, logInstance *zap.Lo
|
||||
}
|
||||
|
||||
// getCfg 读取配置
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:05 2022/6/11
|
||||
func (c *wrapperClient) getCfg(cfgPath string) (*define.CfgFile, error) {
|
||||
fileArr := strings.Split(cfgPath, ".")
|
||||
if len(fileArr) < 2 {
|
||||
@@ -154,10 +138,6 @@ func (c *wrapperClient) getCfg(cfgPath string) (*define.CfgFile, error) {
|
||||
}
|
||||
|
||||
// GetDBClient 获取db client
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 19:32 2022/6/5
|
||||
func (c *wrapperClient) GetDBClient(dbFlag string) (abstract.IWrapperDatabaseClient, error) {
|
||||
c.lock.RLock()
|
||||
defer c.lock.RUnlock()
|
||||
@@ -172,10 +152,6 @@ func (c *wrapperClient) GetDBClient(dbFlag string) (abstract.IWrapperDatabaseCli
|
||||
}
|
||||
|
||||
// GetMasterClient 获取主库客户端
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 19:36 2022/6/5
|
||||
func (c *wrapperClient) GetMasterClient(ctx context.Context, dbFlag string) (*gorm.DB, error) {
|
||||
var (
|
||||
err error
|
||||
@@ -189,10 +165,6 @@ func (c *wrapperClient) GetMasterClient(ctx context.Context, dbFlag string) (*go
|
||||
}
|
||||
|
||||
// GetSlaveClient 获取从库客户端
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 19:37 2022/6/5
|
||||
func (c *wrapperClient) GetSlaveClient(ctx context.Context, dbFlag string) (*gorm.DB, error) {
|
||||
var (
|
||||
err error
|
||||
|
||||
Reference in New Issue
Block a user