client.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package client
  2. import (
  3. "context"
  4. "go-common/app/service/main/location/model"
  5. "go-common/library/net/rpc"
  6. )
  7. const (
  8. _archive = "RPC.Archive"
  9. _archive2 = "RPC.Archive2"
  10. _group = "RPC.Group"
  11. _authPIDs = "RPC.AuthPIDs"
  12. // new
  13. _info = "RPC.Info"
  14. _infos = "RPC.Infos"
  15. _infoComplete = "RPC.InfoComplete"
  16. _infosComplete = "RPC.InfosComplete"
  17. // app id
  18. _appid = "location.service"
  19. )
  20. // Service is resource rpc client.
  21. type Service struct {
  22. client *rpc.Client2
  23. }
  24. // New new a resource rpc client.
  25. func New(c *rpc.ClientConfig) (s *Service) {
  26. s = &Service{}
  27. s.client = rpc.NewDiscoveryCli(_appid, c)
  28. return
  29. }
  30. // Archive get the aid auth.
  31. func (s *Service) Archive(c context.Context, arg *model.Archive) (res *int64, err error) {
  32. res = new(int64)
  33. err = s.client.Call(c, _archive, arg, res)
  34. return
  35. }
  36. // Archive2 get the aid auth.
  37. func (s *Service) Archive2(c context.Context, arg *model.Archive) (res *model.Auth, err error) {
  38. res = new(model.Auth)
  39. err = s.client.Call(c, _archive2, arg, res)
  40. return
  41. }
  42. // Group get the gip auth.
  43. func (s *Service) Group(c context.Context, arg *model.Group) (res *model.Auth, err error) {
  44. res = new(model.Auth)
  45. err = s.client.Call(c, _group, arg, res)
  46. return
  47. }
  48. // AuthPIDs check if ip in pids.
  49. func (s *Service) AuthPIDs(c context.Context, arg *model.ArgPids) (res map[int64]*model.Auth, err error) {
  50. err = s.client.Call(c, _authPIDs, arg, &res)
  51. return
  52. }
  53. // Info get the ip info.
  54. func (s *Service) Info(c context.Context, arg *model.ArgIP) (res *model.Info, err error) {
  55. res = new(model.Info)
  56. err = s.client.Call(c, _info, arg, res)
  57. return
  58. }
  59. // Infos get the ips info.
  60. func (s *Service) Infos(c context.Context, arg []string) (res map[string]*model.Info, err error) {
  61. err = s.client.Call(c, _infos, arg, &res)
  62. return
  63. }
  64. // InfoComplete get the whold ip info.
  65. func (s *Service) InfoComplete(c context.Context, arg *model.ArgIP) (res *model.InfoComplete, err error) {
  66. res = new(model.InfoComplete)
  67. err = s.client.Call(c, _infoComplete, arg, res)
  68. return
  69. }
  70. // InfosComplete get the whold ips infos.
  71. func (s *Service) InfosComplete(c context.Context, arg []string) (res map[string]*model.InfoComplete, err error) {
  72. err = s.client.Call(c, _infosComplete, arg, &res)
  73. return
  74. }