29 lines
653 B
Go
29 lines
653 B
Go
|
|
package impl
|
||
|
|
|
||
|
|
import (
|
||
|
|
"git.apinb.com/bsm-apps/passport/internal/config"
|
||
|
|
"git.apinb.com/bsm-sdk/core/cache/redis"
|
||
|
|
"git.apinb.com/bsm-sdk/core/with"
|
||
|
|
cache "github.com/patrickmn/go-cache"
|
||
|
|
clientv3 "go.etcd.io/etcd/client/v3"
|
||
|
|
"gorm.io/gorm"
|
||
|
|
)
|
||
|
|
|
||
|
|
var (
|
||
|
|
RedisService *redis.RedisClient
|
||
|
|
EtcdService *clientv3.Client
|
||
|
|
DBService *gorm.DB
|
||
|
|
MemoryService *cache.Cache
|
||
|
|
)
|
||
|
|
|
||
|
|
func NewImpl() {
|
||
|
|
// with memory cache
|
||
|
|
MemoryService = with.Memory(nil)
|
||
|
|
// with redis cache
|
||
|
|
RedisService = with.RedisCache(config.Spec.Cache)
|
||
|
|
// with databases
|
||
|
|
DBService = with.Databases(config.Spec.Databases, nil)
|
||
|
|
// with etcd
|
||
|
|
EtcdService = with.Etcd(config.Spec.Etcd)
|
||
|
|
}
|