-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
58 lines (46 loc) · 1004 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package mx
import (
"time"
)
// config var
var (
DefaultMaxIdleConns = 10
DefaultMaxOpenConns = 10
DefaultConfig = Config{
MaxIdleConns: DefaultMaxIdleConns,
MaxOpenConns: DefaultMaxOpenConns,
Timeout: 2 * time.Second,
}
)
// Config 用于创建连接的配置配置
type Config struct {
DataSourceName string
MaxIdleConns int
MaxOpenConns int
Log Logger
Timeout time.Duration
}
type Logger interface {
LogSql(LogSqlData)
ErrSql(LogSqlData)
}
type LogSqlData struct {
Sql string `json:"sql"`
Duration time.Duration `json:"duration"`
Callers LogSqlCallers `json:"callers"`
Way LogSqlWay `json:"way"` // Query Exec
Err error `json:"err"`
}
type LogSqlWay int
var (
QueryWay LogSqlWay = 1
ExecWay LogSqlWay = 2
)
type LogSqlCaller struct {
Function string `json:"function"`
File string `json:"file"`
Line int `json:"line"`
}
type LogSqlCallers []LogSqlCaller
func (config *Config) parse() {
}