client.go 509 B

123456789101112131415161718192021222324
  1. package v1
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/library/net/rpc/warden"
  6. "google.golang.org/grpc"
  7. )
  8. // DiscoveryAppID .
  9. const DiscoveryAppID = "video.live.streamng"
  10. // NewClient 建立grpc连接
  11. func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (StreamClient, error) {
  12. client := warden.NewClient(cfg, opts...)
  13. cc, err := client.Dial(context.Background(), fmt.Sprintf("discovery://default/%s", DiscoveryAppID))
  14. if err != nil {
  15. return nil, err
  16. }
  17. return NewStreamClient(cc), nil
  18. }