Dgraph: Lua/LuaJIT Client

Created on 10 Mar 2017  路  10Comments  路  Source: dgraph-io/dgraph

I would love to see a Lua client usable from OpenResty/LuaJIT/Lua using gRPC.

Bountysource

help wanted

All 10 comments

@manishrjain @hengestone Lua is fun to code and openresty makes it even simpler.Will be interested in coding the lua client.Also if dgraph only supports grpc,need to see if lua grpc libraries are well supported.

dgraph has an HTTP interface too, which is trivial to use. See all the curl examples in the documentation.
This is about the protobuf interface.
Implementing a basic client that sends/receives messages to the dgraph server is relatively simple too, but requires putting together a few pieces:

  1. Use github.com/starwing/lua-protobuf or github.com/Neopallium/lua-pb client to encode/decode messages
  2. Connect to the dgraph server over gRPC.
    2.a. Connecting over HTTP/2 and calling the service endpoints should work.
    2.b. Or for a less ad-hoc implementation binding the C library would be required: www.grpc.io/grpc/core

I'm happy to give the bounty for 1 and 2.a demonstrating sending a query to a Dgraph server and getting a response, with no authentication.

@hengestone Thanks for the detailed info.
Considering the lack of lua grpc support to interact with dgraph, if we are using the http service endpoints then we don't have to even send the query as protobuff encoded message as per the curl examples ? Not sure if you meant these service end points.

Because the examples use curl to directly post to the service endpoint without any encoding as that is done internally by the queryHandler I guess.

Or is it that ,I have to connect to the host:port and send the protobuf encoded messages ?

Will start working on this.Thanks.

@crackerplace Using JSON/HTTP(S) is a good place to start, but using protobuf/gRPC is more efficient by far.

Thanks for taking a look!

@hengestone thanks.I am asking many questions,sorry for that.So are you looking for the latter implementation i.e for "protobuf/gRPC is more efficient by far."

At a high level,Connect to the graph server's port through http2 and send the protobuf encoded request and decode the received response.

You're right, the graphQL+- queries are not JSON, more like RDF. The return values are JSON though, and easily parsed.

So probably not worth pursuing a specialized protobuf client. Thanks again for taking a look :)

Kool.No Issues.

On the other side are there any lua grpc libraries that you are aware of.thanks.

No, not that I could find, which was I was looking for a driver in the first place.

got that.thanks.

If users are interested, they can build this and send us a PR to add this in our unofficial list of clients. This doesn't need to be tracked here, we don't have any plans to build this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marvin-hansen picture marvin-hansen  路  4Comments

protheusfr picture protheusfr  路  4Comments

mbudge picture mbudge  路  3Comments

pepoospina picture pepoospina  路  3Comments

yupengfei picture yupengfei  路  4Comments