item_inventory.pb.go 891 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package proto
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/micros/common"
  5. "context"
  6. "github.com/smallnest/rpcx/client"
  7. )
  8. const ServiceName = "item_inventory"
  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. ExtraData string
  17. }
  18. type Response struct {
  19. Data string
  20. }
  21. func SetConsulAddr(addr string) {
  22. consulAddr = addr
  23. }
  24. func SayHello(name string) string {
  25. xclient := getClient()
  26. //defer xclient.Close()
  27. args := &Request{
  28. Name: name,
  29. }
  30. reply := &Response{}
  31. err := xclient.Call(context.Background(), "SayHello", args, reply)
  32. if err != nil {
  33. log.Debug("item failed to call: %v", err)
  34. common.GetClientPool().RemoveClient(ServiceName)
  35. return ""
  36. }
  37. log.Debug("SayHello return %s", reply.Data)
  38. return reply.Data
  39. }