feat: 迁移plant
This commit is contained in:
@@ -2,6 +2,7 @@ package svc
|
||||
|
||||
import (
|
||||
"sundynix-micro-go/app/auth/api/internal/config"
|
||||
"sundynix-micro-go/app/plant/rpc/plantservice"
|
||||
"sundynix-micro-go/app/system/rpc/systemservice"
|
||||
"sundynix-micro-go/common/utils/captcha"
|
||||
|
||||
@@ -13,6 +14,9 @@ import (
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SystemRpc systemservice.SystemService
|
||||
// 各业务 RPC(可选,新增小程序时在此追加)
|
||||
PlantRpc plantservice.PlantService
|
||||
// RadioRpc radioservice.RadioService
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
@@ -25,8 +29,16 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||
captcha.InitWithRedis(rdb)
|
||||
logx.Infof("验证码存储已切换至 Redis (DB%d)", c.Redis.DB)
|
||||
|
||||
return &ServiceContext{
|
||||
svc := &ServiceContext{
|
||||
Config: c,
|
||||
SystemRpc: systemservice.NewSystemService(zrpc.MustNewClient(c.SystemRpc)),
|
||||
}
|
||||
|
||||
// 可选: PlantRpc(配置了才连接,避免强依赖)
|
||||
if c.PlantRpc.Etcd.Key != "" || len(c.PlantRpc.Endpoints) > 0 {
|
||||
svc.PlantRpc = plantservice.NewPlantService(zrpc.MustNewClient(c.PlantRpc))
|
||||
logx.Info("PlantRpc 已连接")
|
||||
}
|
||||
|
||||
return svc
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user