servicecontext.go 778 B

12345678910111213141516171819202122232425
  1. package svc
  2. import (
  3. "app.yhyue.com/moapp/jyInfo/api/internal/config"
  4. "app.yhyue.com/moapp/jyInfo/rpc/common/commonclient"
  5. "app.yhyue.com/moapp/jyInfo/rpc/consumer/consumerclient"
  6. "app.yhyue.com/moapp/jyInfo/rpc/manager/managerclient"
  7. "github.com/zeromicro/go-zero/zrpc"
  8. )
  9. type ServiceContext struct {
  10. Config config.Config
  11. Common commonclient.CommonClient
  12. Manager managerclient.ManagerClient
  13. Consumer consumerclient.ConsumerClient
  14. }
  15. func NewServiceContext(c config.Config) *ServiceContext {
  16. return &ServiceContext{
  17. Config: c,
  18. Common: commonclient.NewCommonClient(zrpc.MustNewClient(c.Common)),
  19. Manager: managerclient.NewManagerClient(zrpc.MustNewClient(c.Manager)),
  20. Consumer: consumerclient.NewConsumerClient(zrpc.MustNewClient(c.Consumer)),
  21. }
  22. }