rpc.go 923 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package server
  2. import (
  3. "go-common/app/service/main/passport-auth/conf"
  4. "go-common/app/service/main/passport-auth/service"
  5. "go-common/library/net/rpc"
  6. "go-common/library/net/rpc/context"
  7. )
  8. // RPC rpc struct
  9. type RPC struct {
  10. s *service.Service
  11. }
  12. // New new rpc server.
  13. func New(c *conf.Config, s *service.Service) (svr *rpc.Server) {
  14. r := &RPC{s: s}
  15. svr = rpc.NewServer(c.RPCServer)
  16. if err := svr.Register(r); err != nil {
  17. panic(err)
  18. }
  19. return
  20. }
  21. // Ping check connection success.
  22. func (r *RPC) Ping(c context.Context, arg *struct{}, res *struct{}) (err error) {
  23. return
  24. }
  25. // DelTokenCache query token
  26. func (r *RPC) DelTokenCache(c context.Context, token string, res *struct{}) (err error) {
  27. err = r.s.DelTokenCache(c, token)
  28. return
  29. }
  30. // DelCookieCache del cookie
  31. func (r *RPC) DelCookieCache(c context.Context, session string, res *struct{}) (err error) {
  32. err = r.s.DelCookieCache(c, session)
  33. return
  34. }