client.go 513 B

1234567891011121314151617181920212223
  1. package v1
  2. import (
  3. "fmt"
  4. "go-common/library/net/rpc/warden"
  5. context "golang.org/x/net/context"
  6. grpc "google.golang.org/grpc"
  7. )
  8. // AppID .
  9. const AppID = "account.service.coupon"
  10. // NewClient new grpc client
  11. func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (CouponClient, error) {
  12. client := warden.NewClient(cfg, opts...)
  13. cc, err := client.Dial(context.Background(), fmt.Sprintf("discovery://default/%s", AppID))
  14. if err != nil {
  15. return nil, err
  16. }
  17. return NewCouponClient(cc), nil
  18. }