client.go 504 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.vip"
  10. // NewClient new grpc client
  11. func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (VipClient, 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 NewVipClient(cc), nil
  18. }