client.go 578 B

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