sql read write support (#4976)

Co-authored-by: light.zhou <light.zhou@bkyo.io>
This commit is contained in:
zhoushuguang
2025-07-10 00:04:56 +08:00
committed by GitHub
parent 95d5b81f44
commit 8c6266f338
8 changed files with 553 additions and 10 deletions

View File

@@ -0,0 +1,29 @@
package sqlx
import "errors"
var (
errEmptyDatasource = errors.New("empty datasource")
errEmptyDriverName = errors.New("empty driver name")
)
// SqlConf defines the configuration for sqlx.
type SqlConf struct {
DataSource string
DriverName string `json:",default=mysql"`
Replicas []string `json:",optional"`
Policy string `json:",default=round-robin,options=round-robin|random"`
}
// Validate validates the SqlxConf.
func (sc SqlConf) Validate() error {
if len(sc.DataSource) == 0 {
return errEmptyDatasource
}
if len(sc.DriverName) == 0 {
return errEmptyDriverName
}
return nil
}