-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
44 lines (36 loc) · 904 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
package config
import (
minipkg_gorm "github.com/minipkg/db/gorm"
"github.com/minipkg/db/redis"
"github.com/minipkg/log"
)
const DBClusterDefaultSysname = "default"
type Configuration struct {
Infrastructure *Infrastructure
Metadata *Metadata
}
type Infrastructure struct {
Log log.Config
ReferenceDB minipkg_gorm.Config
DataSharding Sharding
SearchDB minipkg_gorm.Config
Redis redis.Config
CacheLifeTime uint
}
type Sharding struct {
IsAutoMigrate bool
Default DBCluster
BySysnames map[string]DBCluster
}
type DBCluster struct {
Capacity uint
EntityTypes []string
Items []minipkg_gorm.Config
}
func (s *Sharding) GetEntityTypesByClusterSysnames() map[string][]string {
types := make(map[string][]string, len(s.BySysnames))
for sysname, cluster := range s.BySysnames {
types[sysname] = cluster.EntityTypes
}
return types
}