client.tmpl 925 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Package client generate by warden_gen
  2. package client
  3. import (
  4. "fmt"
  5. {{range $key, $value := .Imports}}"{{$key}}"
  6. {{end}}{{range $key, $value := .ClientImports}}"{{$key}}"
  7. {{end}}
  8. pb "{{.PbPackage}}"
  9. "go-common/net/rpc/warden"
  10. "go-common/app/warden/balancer/wrr"
  11. "google.golang.org/grpc"
  12. )
  13. const (
  14. treeID = 2233
  15. )
  16. // New {{.Name}} service client
  17. func New(conf *warden.ClientConfig) *Client {
  18. target := fmt.Sprintf("discovery://default/%d", treeID)
  19. wc := warden.NewClient(conf, grpc.WithBalancerName(wrr.Name))
  20. conn, err := wc.Dial(context.TODO(), target)
  21. if err != nil {
  22. panic(err)
  23. }
  24. return &Client{pb.New{{.Name}}Client(conn)}
  25. }
  26. // Client service client
  27. type Client struct {
  28. grpcClient pb.{{.Name}}Client
  29. }
  30. {{range .Methods}}
  31. // {{range .Comments}}{{.}}{{end}}
  32. func (c *Client) {{.Name}}({{.ParamBlock}}) ({{.ReturnBlock}}) {
  33. panic("not implemented")
  34. }
  35. {{end}}