main.go 964 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package main
  2. import (
  3. "context"
  4. "flag"
  5. "fmt"
  6. "log"
  7. "time"
  8. "go-common/app/service/bbq/push/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 init() {
  16. flag.StringVar(&addr, "addr", "127.0.0.1:9000", "server addr")
  17. }
  18. func main() {
  19. flag.Parse()
  20. cfg := &warden.ClientConfig{
  21. Dial: xtime.Duration(time.Second * 3),
  22. Timeout: xtime.Duration(time.Second * 3),
  23. }
  24. cc, err := warden.NewClient(cfg).Dial(context.Background(), addr)
  25. if err != nil {
  26. log.Fatalf("new client failed!err:=%v", err)
  27. return
  28. }
  29. client := v1.NewPushClient(cc)
  30. dev := []*v1.Device{
  31. {
  32. RegisterID: "1a0018970a8ddcaef46",
  33. Platform: 1,
  34. SDK: 1,
  35. SendNo: 1,
  36. },
  37. }
  38. fmt.Println(client.Notification(context.Background(), &v1.NotificationRequest{
  39. Dev: dev,
  40. Body: &v1.NotificationBody{
  41. Title: "test title",
  42. Content: "test content",
  43. Extra: "{\"schema\":\"schema\"}",
  44. },
  45. }))
  46. }