client.go 545 B

123456789101112131415161718192021222324252627
  1. package api
  2. import (
  3. "context"
  4. "google.golang.org/grpc"
  5. "go-common/library/net/rpc/warden"
  6. )
  7. const AppID = "live.xroomfeed"
  8. type Client struct {
  9. RecPoolClient RecPoolClient
  10. }
  11. // NewClient xroom-feed 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/"+AppID)
  15. if err != nil {
  16. return nil, err
  17. }
  18. cli := &Client{}
  19. cli.RecPoolClient = NewRecPoolClient(conn)
  20. return cli, nil
  21. }