/
types.go
69 lines (60 loc) · 1.33 KB
/
types.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
59
60
61
62
63
64
65
66
67
68
69
package gxap
import (
"github.com/go-redis/redis/v8"
"go.uber.org/zap"
"gorm.io/gorm"
"io"
)
type confDb struct {
Dsn string `yaml:"dsn"`
ConnMaxLifeTime int `yaml:"connMaxLifeTime"`
MaxOpenConn int `yaml:"maxOpenConn"`
MaxIdleConn int `yaml:"maxIdleConn"`
TablePrefix string `yaml:"tablePrefix"`
}
type confLog struct {
Filepath string `yaml:"filepath"`
Filename string `yaml:"filename"`
MaxBackups int `yaml:"maxBackups"`
MaxAge int `yaml:"frequency"`
MaxSize int `yaml:"maxSize"`
JsonMode bool `yaml:"jsonMode"`
}
type confRedis struct {
Type string `yaml:"type"`
Addr string `yaml:"addr"`
Password string `yaml:"password"`
Index int `yaml:"index"`
MaxRedirect int `yaml:"max-redirect"`
}
// Conf 配置文件格式
type Conf struct {
Profiles string `yaml:"profiles"`
Log confLog `yaml:"log"`
Db confDb `yaml:"db"`
Redis confRedis `yaml:"redis"`
}
type SysPath struct {
CurDir string
ConfigDir string
}
type IRed interface {
redis.Cmdable
io.Closer
}
type ICtx interface {
GetConfig() Conf
GetDb() *gorm.DB
GetLog() *zap.SugaredLogger
GetSysPath() SysPath
GetRedis() IRed
Close()
}
// Ctx 环境
type Ctx struct {
Config Conf
Db *gorm.DB
Log *zap.SugaredLogger
SysPath SysPath
Redis IRed
}