You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
748 B
35 lines
748 B
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 |
|
}
|
|
|