client.go 539 B

123456789101112131415161718192021222324252627
  1. package v0
  2. import (
  3. "context"
  4. "google.golang.org/grpc"
  5. "go-common/library/net/rpc/warden"
  6. )
  7. const AppID = "live.daoanchor"
  8. type Client struct {
  9. CreateDataClient
  10. }
  11. // NewClient new anchor grpc client
  12. func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (*Client, error) {
  13. client := warden.NewClient(cfg, opts...)
  14. conn, err := client.Dial(context.Background(), "discovery://default/"+AppID)
  15. if err != nil {
  16. return nil, err
  17. }
  18. cli := &Client{}
  19. cli.CreateDataClient = NewCreateDataClient(conn)
  20. return cli, nil
  21. }