main.go 993 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package main
  2. import (
  3. "context"
  4. "flag"
  5. "fmt"
  6. rpc "go-common/app/service/bbq/recsys/api/grpc/v1"
  7. "go-common/library/net/rpc/warden"
  8. xtime "go-common/library/time"
  9. "log"
  10. "time"
  11. )
  12. var name, addr string
  13. func init() {
  14. flag.StringVar(&name, "name", "lily", "name")
  15. flag.StringVar(&addr, "addr", "127.0.0.1:9000", "server addr")
  16. }
  17. func main() {
  18. flag.Parse()
  19. cfg := &warden.ClientConfig{
  20. Dial: xtime.Duration(time.Second * 3),
  21. Timeout: xtime.Duration(time.Second * 3),
  22. }
  23. cc, err := warden.NewClient(cfg).Dial(context.Background(), addr)
  24. if err != nil {
  25. log.Fatalf("new client failed!err:=%v", err)
  26. return
  27. }
  28. var mid int64 = 6622959 //100011563
  29. buvid := "123456"
  30. client := rpc.NewRecsysClient(cc)
  31. resp, err := client.UpsRecService(context.Background(), &rpc.RecsysRequest{
  32. MID: mid,
  33. BUVID: buvid,
  34. Limit: 10,
  35. Offset: 0,
  36. SVID: 114888,
  37. })
  38. if err != nil {
  39. log.Fatalf("say hello failed!err:=%v", err)
  40. return
  41. }
  42. fmt.Printf("got Reply: %+v", resp)
  43. }