rpc.go 869 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package server
  2. import (
  3. "go-common/app/service/main/passport/conf"
  4. "go-common/app/service/main/passport/model"
  5. "go-common/app/service/main/passport/service"
  6. "go-common/library/net/rpc"
  7. "go-common/library/net/rpc/context"
  8. )
  9. // RPC server struct
  10. type RPC struct {
  11. s *service.Service
  12. }
  13. // New new rpc server.
  14. func New(c *conf.Config, s *service.Service) (svr *rpc.Server) {
  15. r := &RPC{s: s}
  16. svr = rpc.NewServer(c.RPCServer)
  17. if err := svr.Register(r); err != nil {
  18. panic(err)
  19. }
  20. return
  21. }
  22. // Ping check connection success.
  23. func (r *RPC) Ping(c context.Context, arg *struct{}, res *struct{}) (err error) {
  24. return
  25. }
  26. // LoginLogs get the latest limit login logs.
  27. func (r *RPC) LoginLogs(c context.Context, arg *model.ArgLoginLogs, res *[]*model.LoginLog) (err error) {
  28. if ms, err := r.s.LoginLogs(c, arg.Mid, arg.Limit); err == nil {
  29. *res = ms
  30. }
  31. return
  32. }