client.go 542 B

12345678910111213141516171819202122232425
  1. package api
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/library/net/rpc/warden"
  6. "google.golang.org/grpc"
  7. )
  8. // AppID .
  9. const AppID = "archive.service"
  10. // NewClient new grpc client
  11. func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (ArchiveClient, 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 NewArchiveClient(cc), nil
  18. }
  19. //go:generate $GOPATH/src/go-common/app/tool/warden/protoc.sh