userservices.pb.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package proto
  2. import (
  3. "context"
  4. "bet24.com/log"
  5. "bet24.com/servers/micros/common"
  6. "github.com/smallnest/rpcx/client"
  7. )
  8. const ServiceName = "userservices"
  9. var consulAddr = common.Default_Consul_Addr
  10. func getClient() client.XClient {
  11. return common.GetClientPool().GetClient(ServiceName, consulAddr)
  12. }
  13. type Request struct {
  14. UserId int
  15. Name string
  16. CountryName string
  17. Currency string
  18. Point int
  19. Level int
  20. GameId int
  21. Score int
  22. DecorationType int
  23. ItemId int
  24. TaskID int
  25. Status int
  26. Charm int
  27. Exp int
  28. UserIds []int
  29. }
  30. type Request_Switch struct {
  31. UserId int
  32. SwitchInfo
  33. }
  34. type Response struct {
  35. RetCode int
  36. Data string
  37. UserInfo *UserHotInfo
  38. Success bool
  39. Level int
  40. Point int
  41. Param int
  42. LevelBase LevelBaseInfo
  43. SwitchList []int
  44. UserInfos []UserHotInfo
  45. SwitchLevelList []SwitchLevel
  46. }
  47. func SetConsulAddr(addr string) {
  48. consulAddr = addr
  49. }
  50. func SayHello(name string) string {
  51. xclient := getClient()
  52. args := &Request{
  53. Name: name,
  54. }
  55. reply := &Response{}
  56. err := xclient.Call(context.Background(), "SayHello", args, reply)
  57. if err != nil {
  58. log.Debug("userservices failed to call: %v", err)
  59. common.GetClientPool().RemoveClient(ServiceName)
  60. return ""
  61. }
  62. log.Debug("SayHello return %s", reply.Data)
  63. return reply.Data
  64. }
  65. func AddUser(userId int) {
  66. xclient := getClient()
  67. //defer xclient.Close()
  68. args := &Request{
  69. UserId: userId,
  70. }
  71. err := xclient.Call(context.Background(), "AddUser", args, nil)
  72. if err != nil {
  73. common.GetClientPool().RemoveClient(ServiceName)
  74. log.Debug("userservice failed to call: %v", err)
  75. }
  76. }
  77. func RemoveUser(userId int) {
  78. xclient := getClient()
  79. //defer xclient.Close()
  80. args := &Request{
  81. UserId: userId,
  82. }
  83. err := xclient.Call(context.Background(), "RemoveUser", args, nil)
  84. if err != nil {
  85. common.GetClientPool().RemoveClient(ServiceName)
  86. log.Debug("level failed to call: %v", err)
  87. }
  88. }