go-common/app/service/live/xuserex/api/grpc/v1/client.go

30 lines
601 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
package v1
import (
"context"
"go-common/library/net/rpc/warden"
"google.golang.org/grpc"
)
// AppID unique app id for service discovery
const AppID = "live.xuserex"
// Client client
type Client struct {
RoomNoticeClient
}
// NewClient new resource 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.RoomNoticeClient = NewRoomNoticeClient(conn)
return cli, nil
}