selmeci / dgraph-tonic

Async/Sync gRPC client for Dgraph DB
MIT License
83 stars 8 forks source link

dgraph-tonic 0.9.0 fails `cargo audit` #33

Closed wimax-grapl closed 2 years ago

wimax-grapl commented 3 years ago

Due to tonic-build 0.4, which depends on prost-types 0.7.

I tried upgrading it to tonic-build 0.5, but got 41 errors, mostly one of:

cannot find type `InterceptedService` in this scope

no method named `accept_gzip` found for struct `tonic::client::Grpc<T>` in the current scope

`<<T as GrpcService<BoxBody>>::ResponseBody as tonic::codegen::HttpBody>::Error` cannot be shared between threads safely
colin-grapl commented 3 years ago

I was trying to get this fixed but it's not straightforward to update the tonic dependencies. The dependencies that must be updated are:

prost = "0.8"
tonic = "0.5"
tonic-build = "0.5"

The problem then is that there's a breaking change in the API. This impacts only the LazyAclClient because its client's type has changed.

https://github.com/selmeci/dgraph-tonic/blob/master/src/client/acl.rs#L41

with_interceptor no longer returns a DgraphClient, leading to this error:

error[E0308]: mismatched types
  --> src/client/acl.rs:49:33
   |
41 |               let client = DgraphClient::with_interceptor(channel, move |mut req: Request<()>| {
   |  __________________________________________________________________-
42 | |                 let token = {
43 | |                     let access_jwt = access_jwt.lock().unwrap();
44 | |                     MetadataValue::from_str(&access_jwt).expect("gRPC metadata")
...  |
47 | |                 Ok(req)
48 | |             });
   | |_____________- the found closure
49 |               self.client.replace(client);
   |                                   ^^^^^^ expected struct `Channel`, found struct `tonic::codegen::InterceptedService`
   |
   = note: expected struct `v1_1_x::api::dgraph_client::DgraphClient<Channel>`
              found struct `v1_1_x::api::dgraph_client::DgraphClient<tonic::codegen::InterceptedService<Channel, [closure@src/client/acl.rs:41:66: 48:14]>>`

Unfortunately, ILazyClient and other areas of the code have the expectation of Channel, and so it's not a straightforward change to fix this.