broadcast.go 941 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package broadcast
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/app/interface/main/app-resource/conf"
  6. pb "go-common/app/service/main/broadcast/api/grpc/v1"
  7. warden "go-common/app/service/main/broadcast/api/grpc/v1"
  8. wardenclient "go-common/app/service/main/broadcast/api/grpc/v1"
  9. "go-common/library/log"
  10. )
  11. type Dao struct {
  12. c *conf.Config
  13. // grpc
  14. rpcClient pb.ZergClient
  15. }
  16. func New(c *conf.Config) (d *Dao) {
  17. d = &Dao{
  18. c: c,
  19. }
  20. var err error
  21. if d.rpcClient, err = wardenclient.NewClient(c.BroadcastRPC); err != nil {
  22. panic(fmt.Sprintf("BroadcastRPC warden.NewClient error (%+v)", err))
  23. }
  24. return
  25. }
  26. // ServerList warden server list
  27. func (d *Dao) ServerList(ctx context.Context, platform string) (res *warden.ServerListReply, err error) {
  28. arg := &warden.ServerListReq{
  29. Platform: platform,
  30. }
  31. if res, err = d.rpcClient.ServerList(ctx, arg); err != nil {
  32. log.Error("d.rpcClient.ServerList error(%v)", err)
  33. return
  34. }
  35. return
  36. }