30 lines
578 B
Go
30 lines
578 B
Go
|
package v1
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"google.golang.org/grpc"
|
||
|
|
||
|
"go-common/library/net/rpc/warden"
|
||
|
)
|
||
|
|
||
|
// AppID discovery id
|
||
|
const AppID = "live.recommend"
|
||
|
|
||
|
// Client recommend client
|
||
|
type Client struct {
|
||
|
RecommendClient
|
||
|
}
|
||
|
|
||
|
// NewClient new grpc client
|
||
|
func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (*Client, error) {
|
||
|
client := warden.NewClient(cfg, opts...)
|
||
|
conn, err := client.Dial(context.Background(), "discovery://default/"+AppID)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
cli := &Client{}
|
||
|
cli.RecommendClient = NewRecommendClient(conn)
|
||
|
return cli, nil
|
||
|
}
|