(project, token string, opts ...Option)
| 32 | } |
| 33 | |
| 34 | func NewClient(project, token string, opts ...Option) (pb.QuickClient, error) { |
| 35 | var o options |
| 36 | for _, apply := range opts { |
| 37 | apply(&o) |
| 38 | } |
| 39 | |
| 40 | dialOpts := []grpc.DialOption{ |
| 41 | grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})), |
| 42 | grpc.WithPerRPCCredentials(basic.NewPerRPCCredentials(project, token)), |
| 43 | grpc.WithUnaryInterceptor(rpc.UnaryInterceptor), |
| 44 | } |
| 45 | |
| 46 | hostname := o.hostname |
| 47 | if hostname == "" { |
| 48 | hostname = defaultHostname |
| 49 | } |
| 50 | |
| 51 | conn, err := grpc.Dial(hostname+":443", dialOpts...) |
| 52 | if err != nil { |
| 53 | return nil, err |
| 54 | } |
| 55 | |
| 56 | return pb.NewQuickClient(conn), nil |
| 57 | } |
no outgoing calls
no test coverage detected