33 lines
671 B
Go
33 lines
671 B
Go
package service
|
|
|
|
import (
|
|
"bsm/full/module/base/mgt/internal/impl"
|
|
"git.apinb.com/bsm-sdk/core/cache/redis"
|
|
cache "github.com/patrickmn/go-cache"
|
|
clientv3 "go.etcd.io/etcd/client/v3"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// Dependencies contains shared infrastructure supplied by the all module.
|
|
type Dependencies struct {
|
|
Redis *redis.RedisClient
|
|
Etcd *clientv3.Client
|
|
DB *gorm.DB
|
|
Cache *cache.Cache
|
|
}
|
|
|
|
func applyDependencies(deps Dependencies) {
|
|
if deps.Redis != nil {
|
|
impl.RedisService = deps.Redis
|
|
}
|
|
if deps.Etcd != nil {
|
|
impl.EtcdService = deps.Etcd
|
|
}
|
|
if deps.DB != nil {
|
|
impl.DBService = deps.DB
|
|
}
|
|
if deps.Cache != nil {
|
|
impl.MemorySerice = deps.Cache
|
|
}
|
|
}
|