Setting deadlines/timeouts on individual calls

Moved from GitHub dgraph-js/16

Posted by tav:

Would it be possible to add support for setting deadlines on individual calls with the dgraph-js client?

Perhaps the calls could take an optional options parameter? e.g.

await txn.mutate(mu, {deadline: 1516844615385})

As far as I can tell, the Dgraph Go client supports enforcing deadlines on individual calls, and from briefly looking at the Node.js gRPC implementation, it seems to support CallOptions with a deadline property too. So it should hopefully be just a matter of threading it through via the wrapper functions?

gpahal commented :

Yes, this is possible and I think this will be a good addition. I will add an option parameter to individual method calls and also to the DgraphClientStub contructor (https://grpc.io/grpc/node/grpc.Client.html).

tav commented :

Thanks @gpahal!

gpahal commented :

I’ve added the basic functionality in v1.0.4-beta.3. It’s available with the next tag:

npm install dgraph-js@next grpc --save

You can pass an additional argument of type grpc.CallOptions to the DgraphClient#alter, Txn#query, Txn#queryWithVars, Txn#mutate, Txn#commit and Txn#discard methods.

gpahal commented :

Done in v1.0.4