client.go 458 B

123456789101112131415161718192021
  1. package api
  2. import (
  3. "context"
  4. "go-common/library/net/rpc/warden"
  5. "google.golang.org/grpc"
  6. )
  7. // AppID discovery id.
  8. const AppID = "main.admin.manager"
  9. // NewClient .
  10. func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (PermitClient, error) {
  11. client := warden.NewClient(cfg, opts...)
  12. conn, err := client.Dial(context.Background(), "discovery://default/"+AppID)
  13. if err != nil {
  14. return nil, err
  15. }
  16. return NewPermitClient(conn), nil
  17. }