rpc.go 694 B

123456789101112131415161718192021222324252627282930313233
  1. package server
  2. import (
  3. "go-common/app/service/main/assist/conf"
  4. "go-common/app/service/main/assist/service"
  5. "go-common/library/net/rpc"
  6. "go-common/library/net/rpc/context"
  7. )
  8. // RPC rpc.
  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. // Auth check connection success.
  22. func (r *RPC) Auth(c context.Context, arg *rpc.Auth, res *struct{}) (err error) {
  23. return
  24. }
  25. // Ping check connection success.
  26. func (r *RPC) Ping(c context.Context, arg *struct{}, res *struct{}) (err error) {
  27. return
  28. }