Date
1 - 8 of 8
Best practice setup for Go driver development & identifying the websocket serialization format
Ray Scott <raya...@...>
I want to develop a driver in Go that connects to Gremlin Server using a websocket, runs a parameterized Groovy script and parses the response. At this stage all I need to do is perform basic queries and modify the graph. I've read through the documentation on driver development, and looked through some source code for existing drivers.
I receive this...
What format is that? How do other driver developers handle this? Do I need to change the settings of the serializers in the yaml config? Do I use a writer in the Groovy script to serialize the result into a format of my choice? I don't want to perform any unnecessary serialization.
Connecting and sending the data is the easy part. What I can not find anywhere, is an explanation of what I can expect to receive back in terms of the serialised format. I'm actually using JanusGraph straight out the box. I've looked at the yaml config and read some posts on the serializers listed therein. I've read a little about GraphSON and GraphML and Kryo and all I'm really looking for is a way to setup the server so that it returns a response thats some sort of official spec'd format that I can work with in Go. The only other thing I need to do, is be able to use the console as normal.
As an example, if I send this query...
graph = JanusGraphFactory.open(cassandra)
g = graph.traversal()
g.V().has('name', 'hercules').next()
I receive this...
[[map[id:8376 label:demigod type:vertex properties:map[name:[map[id:2s7-6go-sl value:hercules]] age:[map[id:36f-6go-35x value:30]]]]]]
What format is that? How do other driver developers handle this? Do I need to change the settings of the serializers in the yaml config? Do I use a writer in the Groovy script to serialize the result into a format of my choice? I don't want to perform any unnecessary serialization.
Thanks.
loh...@...
The server serializes the response in whichever format has been requested by the client. I'd imagine what you're seeing would be the unmarshalled version of the returned JSON that your go websockets library created.
On Friday, August 4, 2017 at 3:40:44 PM UTC-4, Ray Scott wrote:
I want to develop a driver in Go that connects to Gremlin Server using a websocket, runs a parameterized Groovy script and parses the response. At this stage all I need to do is perform basic queries and modify the graph. I've read through the documentation on driver development, and looked through some source code for existing drivers.Connecting and sending the data is the easy part. What I can not find anywhere, is an explanation of what I can expect to receive back in terms of the serialised format. I'm actually using JanusGraph straight out the box. I've looked at the yaml config and read some posts on the serializers listed therein. I've read a little about GraphSON and GraphML and Kryo and all I'm really looking for is a way to setup the server so that it returns a response thats some sort of official spec'd format that I can work with in Go. The only other thing I need to do, is be able to use the console as normal.As an example, if I send this query...
graph = JanusGraphFactory.open(cassandra)
g = graph.traversal()
g.V().has('name', 'hercules').next()
I receive this...
[[map[id:8376 label:demigod type:vertex properties:map[name:[map[id:2s7-6go-sl value:hercules]] age:[map[id:36f-6go-35x value:30]]]]]]
What format is that? How do other driver developers handle this? Do I need to change the settings of the serializers in the yaml config? Do I use a writer in the Groovy script to serialize the result into a format of my choice? I don't want to perform any unnecessary serialization.Thanks.
Ray Scott <raya...@...>
Do you have a reference for that setting the response format? The driver documentation doesn't mention it, only that you can specify the format of the request. There is an example response in JSON, but it's nothing like what I receive as a response. This is in the Tinkerpop docs. Janus seem to have removed driver development documentation from their release.
http://tinkerpop.apache.org/docs/3.2.5/dev/provider/#_graph_driver_provider_requirements
http://tinkerpop.apache.org/docs/3.2.5/dev/provider/#_graph_driver_provider_requirements
loh...@...
What you're receiving looks a lot like the `data` section of the response JSON. Not knowing what client you're using, I can't say that's normal behaviour, but I've seen http clients behave similarly. As for "setting" the response format, I believe it's however the request is serialized e.g. json is serialized back as json, kryo is serialized back as kryo.
On Friday, August 4, 2017 at 5:14:23 PM UTC-4, Ray Scott wrote:
Do you have a reference for that setting the response format? The driver documentation doesn't mention it, only that you can specify the format of the request. There is an example response in JSON, but it's nothing like what I receive as a response. This is in the Tinkerpop docs. Janus seem to have removed driver development documentation from their release.http://tinkerpop.apache.org/
docs/3.2.5/dev/provider/#_ graph_driver_provider_ requirements
Ray Scott <raya...@...>
That makes sense to me. Is there a suggested way to format data in the `data` section. I realise you can write a script to output anything you wish, but if I'm, say, wanting to do CRUD style work on a vertex, is there an efficient and non-error prone way to represent that data if I perform a read on that vertex? I'm fetching it from Go code.
On Monday, 7 August 2017 15:06:29 UTC+1, Keith Lohnes wrote:
What you're receiving looks a lot like the `data` section of the response JSON. Not knowing what client you're using, I can't say that's normal behaviour, but I've seen http clients behave similarly. As for "setting" the response format, I believe it's however the request is serialized e.g. json is serialized back as json, kryo is serialized back as kryo.
On Friday, August 4, 2017 at 5:14:23 PM UTC-4, Ray Scott wrote:Do you have a reference for that setting the response format? The driver documentation doesn't mention it, only that you can specify the format of the request. There is an example response in JSON, but it's nothing like what I receive as a response. This is in the Tinkerpop docs. Janus seem to have removed driver development documentation from their release.http://tinkerpop.apache.org/
docs/3.2.5/dev/provider/#_ graph_driver_provider_ requirements
Robert Dale <rob...@...>
Have you seen this Go client? https://github.com/qasaur/gremgo
On Friday, August 4, 2017 at 3:40:44 PM UTC-4, Ray Scott wrote:
I want to develop a driver in Go that connects to Gremlin Server using a websocket, runs a parameterized Groovy script and parses the response. At this stage all I need to do is perform basic queries and modify the graph. I've read through the documentation on driver development, and looked through some source code for existing drivers.Connecting and sending the data is the easy part. What I can not find anywhere, is an explanation of what I can expect to receive back in terms of the serialised format. I'm actually using JanusGraph straight out the box. I've looked at the yaml config and read some posts on the serializers listed therein. I've read a little about GraphSON and GraphML and Kryo and all I'm really looking for is a way to setup the server so that it returns a response thats some sort of official spec'd format that I can work with in Go. The only other thing I need to do, is be able to use the console as normal.As an example, if I send this query...
graph = JanusGraphFactory.open(cassandra)
g = graph.traversal()
g.V().has('name', 'hercules').next()
I receive this...
[[map[id:8376 label:demigod type:vertex properties:map[name:[map[id:2s7-6go-sl value:hercules]] age:[map[id:36f-6go-35x value:30]]]]]]
What format is that? How do other driver developers handle this? Do I need to change the settings of the serializers in the yaml config? Do I use a writer in the Groovy script to serialize the result into a format of my choice? I don't want to perform any unnecessary serialization.Thanks.
Ray Scott <raya...@...>
That's what I'm using.
On Monday, 7 August 2017 16:29:08 UTC+1, Robert Dale wrote:
Have you seen this Go client? https://github.com/qasaur/gremgo
On Friday, August 4, 2017 at 3:40:44 PM UTC-4, Ray Scott wrote:I want to develop a driver in Go that connects to Gremlin Server using a websocket, runs a parameterized Groovy script and parses the response. At this stage all I need to do is perform basic queries and modify the graph. I've read through the documentation on driver development, and looked through some source code for existing drivers.Connecting and sending the data is the easy part. What I can not find anywhere, is an explanation of what I can expect to receive back in terms of the serialised format. I'm actually using JanusGraph straight out the box. I've looked at the yaml config and read some posts on the serializers listed therein. I've read a little about GraphSON and GraphML and Kryo and all I'm really looking for is a way to setup the server so that it returns a response thats some sort of official spec'd format that I can work with in Go. The only other thing I need to do, is be able to use the console as normal.As an example, if I send this query...
graph = JanusGraphFactory.open(cassandra)
g = graph.traversal()
g.V().has('name', 'hercules').next()
I receive this...
[[map[id:8376 label:demigod type:vertex properties:map[name:[map[id:2s7-6go-sl value:hercules]] age:[map[id:36f-6go-35x value:30]]]]]]
What format is that? How do other driver developers handle this? Do I need to change the settings of the serializers in the yaml config? Do I use a writer in the Groovy script to serialize the result into a format of my choice? I don't want to perform any unnecessary serialization.Thanks.
John Helmsen <john....@...>
I don't think that you have a serialization problem here, but more of an idiosyncrasy of how gremgo works. I've used it a bit, and whenever gremgo returns a value, it returns it using an empty interface construction, or perhaps an array of empty interfaces:
https://tour.golang.org/methods/14
The object -> string system in Go is actually quite smart, and unwraps your empty interface to a string when it prints out the answer. The format you are seeing is the result of this transformation.
The empty interface is used as the return type, since all different types of data could be contained inside. You will have to write your own code to perform the unwrapping in order to work with the contained data.