main.go 855 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package main
  2. import (
  3. "context"
  4. "flag"
  5. "go-common/app/service/live/xuserex/api/grpc/v1"
  6. "log"
  7. "time"
  8. "fmt"
  9. "go-common/library/net/rpc/warden"
  10. xtime "go-common/library/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:9004", "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. client := v1.NewRoomNoticeClient(cc)
  29. resp, err := client.BuyGuard(context.Background(), &v1.RoomNoticeBuyGuardReq{
  30. Uid: 10000,
  31. TargetId: 11,
  32. })
  33. fmt.Printf("****** buyguard :******* \n %v \n %v \n", resp, err)
  34. }