Documentation ¶
Index ¶
- Constants
- Variables
- func Deregister(name string)
- func GetDbType(dbtype string) (reflect.Type, bool)
- func NewBuilder() container.StandardBuilder
- func NewError(err error, execSql string, args []interface{}) error
- func NewPanicError(err error, strace string) error
- func Register(resolver Resover)
- func RegisterDbType(dbType string, reflectType reflect.Type) (err error)
- func RegistryLogger(logger Logger)
- type Config
- type DbConn
- type DbError
- type DbParam
- type Executer
- type IDB
- type ITrans
- type InvalidArgTypeError
- type Logger
- type MissError
- type MissListError
- type Option
- type PanicError
- type RawMessage
- type Resover
- type Result
- type Row
- type Rows
- type StandardDB
- type TransactionCallback
Constants ¶
View Source
const ( MissTypeParam = "param" MissTypeOper = "oper" )
View Source
const DbTypeNode = "dbs"
Variables ¶
View Source
var ( SecretKey = "glue.xdb12345678" SecretMode = "cbc/pkcs7" BaseSecretEnvName = "BASE_SECRET_ENV_NAME" )
View Source
var ConnRefactor func(connName string, cfg *Config) (newcfg *Config, err error)
数据库连接重构方法
View Source
var (
DateFormat = "2006-01-02 15:04:05"
)
View Source
var DecryptConn func(connName, conn string) (newConn string, err error) = defaultDecryptConn
View Source
var Default = &Config{ MaxOpen: 10, MaxIdle: 5, LifeTime: 600, ShowQueryLog: false, LongQueryTime: 500, LoggerName: "dbslowsql", Debug: false, }
Functions ¶
func NewBuilder ¶
func NewBuilder() container.StandardBuilder
func NewPanicError ¶ added in v0.2.0
func RegisterDbType ¶ added in v0.2.5
func RegistryLogger ¶ added in v0.1.31
func RegistryLogger(logger Logger)
Types ¶
type Config ¶ added in v0.2.3
type Config struct { Proto string `json:"proto" valid:"required"` Conn string `json:"conn" valid:"required" label:"连接字符串"` MaxOpen int `json:"max_open" valid:"required" label:"最大打开连接数"` MaxIdle int `json:"max_idle" valid:"required" label:"最大空闲连接数"` LifeTime int `json:"life_time" valid:"required" label:"单个连接时长(秒)"` ShowQueryLog bool `json:"show_query_log" label:"开启慢查询日志"` LongQueryTime int `json:"long_query_time" label:"慢查询阈值(毫秒)"` LoggerName string `json:"logger_name" label:"日志提供程序"` Debug bool `json:"debug" label:"调试模式"` // contains filtered or unexported fields }
type Executer ¶
type Executer interface { Query(ctx context.Context, sql string, input any) (data Rows, err error) Multi(ctx context.Context, sql string, input any) (data []Rows, err error) First(ctx context.Context, sql string, input any) (data Row, err error) Scalar(ctx context.Context, sql string, input any) (data interface{}, err error) Exec(ctx context.Context, sql string, input any) (r Result, err error) QueryAs(ctx context.Context, sql string, input any, result any) (err error) FirstAs(ctx context.Context, sql string, input any, result any) (err error) }
Executer 数据库操作对象集合
type IDB ¶
type IDB interface { Executer Begin() (ITrans, error) Close() error GetImpl() interface{} Transaction(TransactionCallback) error }
IDB 数据库操作接口
type InvalidArgTypeError ¶ added in v0.5.0
func (InvalidArgTypeError) Error ¶ added in v0.5.0
func (e InvalidArgTypeError) Error() string
type Logger ¶ added in v0.1.31
type MissError ¶ added in v0.5.1
func NewMissOperError ¶ added in v0.5.1
func NewMissParamError ¶ added in v0.5.0
type MissListError ¶ added in v0.5.1
type MissListError interface {
Error() string
}
func NewMissListError ¶ added in v0.5.1
func NewMissListError(errList ...MissError) MissListError
type Option ¶ added in v0.2.3
type Option func(*Config)
Option 配置选项
func WithLifeTime ¶ added in v0.2.3
func WithLoggerName ¶ added in v0.2.3
func WithLongQueryTime ¶ added in v0.2.3
func WithMaxIdle ¶ added in v0.2.3
func WithMaxOpen ¶ added in v0.2.3
func WithShowQueryLog ¶ added in v0.2.3
type PanicError ¶ added in v0.2.0
type RawMessage ¶ added in v0.1.41
type RawMessage []byte
func (RawMessage) MarshalJSON ¶ added in v0.1.41
func (m RawMessage) MarshalJSON() ([]byte, error)
MarshalJSON returns m as the JSON encoding of m.
func (*RawMessage) UnmarshalJSON ¶ added in v0.1.41
func (m *RawMessage) UnmarshalJSON(data []byte) error
UnmarshalJSON sets *m to a copy of data.
type Resover ¶ added in v0.1.2
type Resover interface { Name() string Resolve(connName string, setting config.Config, opts ...Option) (interface{}, error) }
dbResover 定义配置文件转换方法
type StandardDB ¶
type StandardDB interface { GetDB(name string, opts ...Option) (q IDB) GetImpl(name string, opts ...Option) interface{} }
StandardDB
func NewStandardDB ¶
func NewStandardDB(container container.Container) StandardDB
NewStandardDBs 创建DB
type TransactionCallback ¶ added in v0.2.0
Click to show internal directories.
Click to hide internal directories.