server.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Package server generate by warden_gen
  2. package server
  3. import (
  4. "context"
  5. v1 "go-common/app/service/main/vipinfo/api"
  6. service "go-common/app/service/main/vipinfo/service"
  7. "go-common/library/net/rpc/warden"
  8. )
  9. // New VipInfo warden rpc server
  10. func New(c *warden.ServerConfig, svr *service.Service) *warden.Server {
  11. ws := warden.NewServer(c)
  12. v1.RegisterVipInfoServer(ws.Server(), &server{svr})
  13. ws, err := ws.Start()
  14. if err != nil {
  15. panic(err)
  16. }
  17. return ws
  18. }
  19. type server struct {
  20. svr *service.Service
  21. }
  22. var _ v1.VipInfoServer = &server{}
  23. // Info get vipinfo by mid.
  24. func (s *server) Info(ctx context.Context, req *v1.InfoReq) (res *v1.InfoReply, err error) {
  25. var info *v1.ModelInfo
  26. if info, err = s.svr.Info(ctx, req.Mid); err != nil {
  27. return
  28. }
  29. return &v1.InfoReply{Res: info}, nil
  30. }
  31. // Infos get vipinfos by mids
  32. func (s *server) Infos(ctx context.Context, req *v1.InfosReq) (res *v1.InfosReply, err error) {
  33. var infos map[int64]*v1.ModelInfo
  34. if infos, err = s.svr.Infos(ctx, req.Mids); err != nil {
  35. return
  36. }
  37. return &v1.InfosReply{Res: infos}, nil
  38. }