main.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package main
  2. import (
  3. "context"
  4. "flag"
  5. "fmt"
  6. "log"
  7. "time"
  8. "go-common/app/service/bbq/recsys-recall/api/grpc/v1"
  9. "go-common/library/net/rpc/warden"
  10. xtime "go-common/library/time"
  11. )
  12. var (
  13. addr string
  14. )
  15. func test1(client v1.RecsysRecallClient) {
  16. var infos []*v1.RecallInfo
  17. // infos = append(infos, &v1.RecallInfo{
  18. // Tag: "HOT_T1:30",
  19. // Name: "HOT",
  20. // Priority: 1,
  21. // Limit: 20,
  22. // })
  23. // infos = append(infos, &v1.RecallInfo{
  24. // Tag: "RECALL:HOT_T:10053",
  25. // Name: "op",
  26. // Scorer: "default",
  27. // Filter: "bloomfilter",
  28. // Priority: 2,
  29. // Limit: 10,
  30. // })
  31. infos = append(infos, &v1.RecallInfo{
  32. Tag: "RECALL:HOT_T:92",
  33. Name: "175",
  34. Scorer: "default",
  35. Filter: "bloomfilter",
  36. Priority: 1,
  37. Limit: 5,
  38. })
  39. // infos = append(infos, &v1.RecallInfo{
  40. // Tag: "bbq:recall:tagid:11",
  41. // Name: "11",
  42. // Limit: 20,
  43. // })
  44. // infos = append(infos, &v1.RecallInfo{
  45. // Tag: "bbq:recall:tagid:802",
  46. // Name: "802",
  47. // Limit: 20,
  48. // })
  49. // infos = append(infos, &v1.RecallInfo{
  50. // Tag: "bbq:recall:tagid:159",
  51. // Name: "159",
  52. // Limit: 20,
  53. // })
  54. // infos = append(infos, &v1.RecallInfo{
  55. // Tag: "bbq:recall:tagid:1604",
  56. // Name: "1604",
  57. // Priority: 20,
  58. // Limit: 20,
  59. // })
  60. req := &v1.RecallRequest{
  61. MID: 5829468,
  62. BUVID: "d9972de637d2f3b8939ee628a7ea789b",
  63. Infos: infos,
  64. TotalLimit: 20,
  65. }
  66. resp, _ := client.Recall(context.Background(), req)
  67. fmt.Println(resp)
  68. // if err != nil {
  69. // fmt.Println(err)
  70. // return
  71. // }
  72. for _, v := range resp.List {
  73. fmt.Println(v)
  74. }
  75. // for _, v := range resp.SrcInfo {
  76. // fmt.Println(v)
  77. // }
  78. }
  79. // func test2(client v1.RecsysRecallClient) {
  80. // request := &v1.VideoIndexRequest{
  81. // SVIDs: []int64{265375},
  82. // }
  83. // resp, err := client.VideoIndex(context.Background(), request)
  84. // if err != nil {
  85. // fmt.Println(err)
  86. // return
  87. // }
  88. // fmt.Println(resp)
  89. // }
  90. func init() {
  91. flag.StringVar(&addr, "addr", "127.0.0.1:9000", "server addr")
  92. }
  93. func main() {
  94. flag.Parse()
  95. cfg := &warden.ClientConfig{
  96. Dial: xtime.Duration(time.Second * 3),
  97. Timeout: xtime.Duration(time.Second * 3),
  98. }
  99. cc, err := warden.NewClient(cfg).Dial(context.Background(), addr)
  100. if err != nil {
  101. log.Fatalf("new client failed!err:=%v", err)
  102. return
  103. }
  104. client := v1.NewRecsysRecallClient(cc)
  105. test1(client)
  106. // test2(client)
  107. }