| 62 | } |
| 63 | |
| 64 | func (c *DCloudCluster) Client() (*dgraphapi.GrpcClient, func(), error) { |
| 65 | var conns []*grpc.ClientConn |
| 66 | conn, err := dgo.DialCloud(c.url, c.token) |
| 67 | if err != nil { |
| 68 | return nil, nil, errors.Wrap(err, "error creating dgraph client") |
| 69 | } |
| 70 | conns = append(conns, conn) |
| 71 | |
| 72 | cleanup := func() { |
| 73 | for _, conn := range conns { |
| 74 | if err := conn.Close(); err != nil { |
| 75 | log.Printf("[WARNING] error closing connection: %v", err) |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | client := dgo.NewDgraphClient(api.NewDgraphClient(conn)) |
| 80 | return &dgraphapi.GrpcClient{Dgraph: client}, cleanup, nil |
| 81 | } |
| 82 | |
| 83 | func (c *DCloudCluster) HTTPClient() (*dgraphapi.HTTPClient, error) { |
| 84 | return nil, errNotImplemented |