client.go 537 B

12345678910111213141516171819202122232425
  1. package v1
  2. import (
  3. "context"
  4. "go-common/library/net/rpc/warden"
  5. "google.golang.org/grpc"
  6. )
  7. const kAppID = "live.broadcastproxy"
  8. type Client struct {
  9. DanmakuClient
  10. }
  11. // NewClient new resource grpc client
  12. func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (*Client, error) {
  13. client := warden.NewClient(cfg, opts...)
  14. conn, err := client.Dial(context.Background(), "discovery://default/"+kAppID)
  15. if err != nil {
  16. return nil, err
  17. }
  18. cli := &Client{}
  19. cli.DanmakuClient = NewDanmakuClient(conn)
  20. return cli, nil
  21. }