Files
ocean/gateway/internal/svc/servicecontext.go

24 lines
534 B
Go

package svc
import (
"godemo/category/category"
"godemo/gateway/internal/config"
"godemo/user/user"
"github.com/zeromicro/go-zero/zrpc"
)
type ServiceContext struct {
Config config.Config
UserRpc user.UserClient
CategoryRpc category.CategoryClient
}
func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{
Config: c,
UserRpc: user.NewUserClient(zrpc.MustNewClient(c.UserRpc).Conn()),
CategoryRpc: category.NewCategoryClient(zrpc.MustNewClient(c.CategoryRpc).Conn()),
}
}