match.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package client
  2. import (
  3. "context"
  4. matmdl "go-common/app/interface/main/activity/model/like"
  5. "go-common/library/net/rpc"
  6. )
  7. const (
  8. _matchs = "RPC.Matchs"
  9. _subjectUp = "RPC.SubjectUp"
  10. _likeUp = "RPC.LikeUp"
  11. _addLikeCtimeCache = "RPC.AddLikeCtimeCache"
  12. _delLikeCtimeCache = "RPC.DelLikeCtimeCache"
  13. _actSubject = "RPC.ActSubject"
  14. _actProtocol = "RPC.ActProtocol"
  15. )
  16. const (
  17. _appid = "activity.service"
  18. )
  19. var (
  20. _noArg = &struct{}{}
  21. )
  22. // Service struct info.
  23. type Service struct {
  24. client *rpc.Client2
  25. }
  26. // New new service instance and return.
  27. func New(c *rpc.ClientConfig) (s *Service) {
  28. s = &Service{}
  29. s.client = rpc.NewDiscoveryCli(_appid, c)
  30. return
  31. }
  32. // Matchs receive matchs
  33. func (s *Service) Matchs(c context.Context, arg *matmdl.ArgMatch) (res []*matmdl.Match, err error) {
  34. err = s.client.Call(c, _matchs, arg, &res)
  35. return
  36. }
  37. // SubjectUp update act_subject cache.
  38. func (s *Service) SubjectUp(c context.Context, arg *matmdl.ArgSubjectUp) (err error) {
  39. return s.client.Call(c, _subjectUp, arg, _noArg)
  40. }
  41. // LikeUp update likes cache
  42. func (s *Service) LikeUp(c context.Context, arg *matmdl.ArgLikeUp) (err error) {
  43. return s.client.Call(c, _likeUp, arg, _noArg)
  44. }
  45. //AddLikeCtimeCache add like ctime cache
  46. func (s *Service) AddLikeCtimeCache(c context.Context, arg *matmdl.ArgLikeUp) (err error) {
  47. return s.client.Call(c, _addLikeCtimeCache, arg, _noArg)
  48. }
  49. // DelLikeCtimeCache del like ctime cache
  50. func (s *Service) DelLikeCtimeCache(c context.Context, arg *matmdl.ArgLikeItem) (err error) {
  51. return s.client.Call(c, _delLikeCtimeCache, arg, _noArg)
  52. }
  53. // ActSubject get act subject item.
  54. func (s *Service) ActSubject(c context.Context, arg *matmdl.ArgActSubject) (res *matmdl.SubjectItem, err error) {
  55. err = s.client.Call(c, _actSubject, arg, &res)
  56. return
  57. }
  58. // ActProtocol get protocol message
  59. func (s *Service) ActProtocol(c context.Context, arg *matmdl.ArgActProtocol) (res *matmdl.SubProtocol, err error) {
  60. err = s.client.Call(c, _actProtocol, arg, &res)
  61. return
  62. }