-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfactory.go
More file actions
45 lines (38 loc) · 693 Bytes
/
Copy pathfactory.go
File metadata and controls
45 lines (38 loc) · 693 Bytes
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
package sqldata
import "context"
//Factory define factory config
type Factory struct {
db configDb `toml:"database"`
mock SQLData
}
//NewFactory factory
func NewFactory(config *Config) *Factory {
return &Factory{
db: config.Db,
}
}
//New new implSqlData
func (f *Factory) New(ctx context.Context) (re SQLData) {
if f.mock != nil {
re = f.mock
} else {
tmpConndb, _ := newConnDb(&f.db)
re = &implSQLData{
ctx: ctx,
conndb: tmpConndb,
}
}
return
}
//SetMock set mock
func (f *Factory) SetMock(mock SQLData) {
f.mock = mock
}
//ResetMock set mock
func (f *Factory) ResetMock() {
f.SetMock(nil)
}
//Ping check
func (f *Factory) Ping() (err error) {
return
}