dgraph icon indicating copy to clipboard operation
dgraph copied to clipboard

Lua/LuaJIT Client

Open hengestone opened this issue 9 years ago • 10 comments

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

Bountysource

hengestone avatar Mar 10 '17 19:03 hengestone

@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.

nexthack avatar Apr 18 '17 19:04 nexthack

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 avatar Apr 19 '17 16:04 hengestone

@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.

nexthack avatar Apr 19 '17 20:04 nexthack

@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 avatar Apr 20 '17 19:04 hengestone

@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.

nexthack avatar Apr 20 '17 19:04 nexthack

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 :)

hengestone avatar Apr 20 '17 20:04 hengestone

Kool.No Issues.

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

nexthack avatar Apr 20 '17 20:04 nexthack

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

hengestone avatar Apr 20 '17 20:04 hengestone

got that.thanks.

nexthack avatar Apr 20 '17 20:04 nexthack

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.

manishrjain avatar Jan 11 '19 03:01 manishrjain