bilibili-backup/app/service/openplatform/ticket-sales/api/grpc/v1/client.go

36 lines
748 B
Go
Raw Permalink Normal View History

2019-04-22 10:59:20 +08:00
package v1
import (
"context"
"fmt"
"go-common/library/net/rpc/warden"
"google.golang.org/grpc"
)
// AppID 本服务的discoveryID
const AppID = "ticket.service.sales"
// TradeSalesClient .
type TradeSalesClient interface {
TradeClient
PromotionClient
}
var _ TradeSalesClient = client{}
type client struct {
TradeClient
PromotionClient
}
// NewClient include TradeClient adn SalesClient
func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (TradeSalesClient, error) {
cc, err := warden.NewClient(cfg, opts...).Dial(context.Background(), fmt.Sprintf("discovery://default/%s", AppID))
if err != nil {
return nil, err
}
return client{TradeClient: NewTradeClient(cc), PromotionClient: NewPromotionClient(cc)}, nil
}