2 Star 0 Fork 0

广东宇凌网络科技有限公司/simple-iot-basic-rpc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
service_context.go 923 Bytes
一键复制 编辑 原始数据 按行查看 历史
HienGee 提交于 2024-04-30 14:27 . 更新依赖
package svc
import (
"gitee.com/yuLingNet/simple-iot-basic-rpc/ent"
_ "gitee.com/yuLingNet/simple-iot-basic-rpc/ent/runtime"
"gitee.com/yuLingNet/simple-iot-basic-rpc/internal/config"
coreEnt "github.com/suyuan32/simple-admin-core/rpc/ent"
"github.com/redis/go-redis/v9"
"github.com/zeromicro/go-zero/core/logx"
)
type ServiceContext struct {
Config config.Config
DB *ent.Client
DBCore *coreEnt.Client
Redis redis.UniversalClient
}
func NewServiceContext(c config.Config) *ServiceContext {
db := ent.NewClient(
ent.Log(logx.Info), // logger
ent.Driver(c.DatabaseConf.NewNoCacheDriver()),
ent.Debug(), // debug mode
)
coreDb := coreEnt.NewClient(
coreEnt.Log(logx.Info), // logger
coreEnt.Driver(c.DatabaseConf.NewNoCacheDriver()),
coreEnt.Debug(), // debug mode
)
return &ServiceContext{
Config: c,
DB: db,
DBCore: coreDb,
Redis: c.RedisConf.MustNewUniversalRedis(),
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/yuLingNet/simple-iot-basic-rpc.git
git@gitee.com:yuLingNet/simple-iot-basic-rpc.git
yuLingNet
simple-iot-basic-rpc
simple-iot-basic-rpc
ca5a4cf0cee7

搜索帮助