zlfben
zlfben
ATApache TinkerPop
Created by zlfben on 4/17/2024 in #questions
Unable to deserialize results with Gremlin-go client + JanusGraph
Hi all - I'm trying to set up a JanusGraph database and use the Gremlin-go client to run some gremlin traversals over it. I'm facing some serialization error. My docker-compose file to start a JanusGraph at localhost:8182:
version: '3'
services:
janusgraph:
image: janusgraph/janusgraph:1.0.0 # Use the latest JanusGraph image
container_name: jce-janusgraph
ports:
- "8182:8182" # Map the Gremlin server port to the host
environment:
JANUS_PROPS_TEMPLATE: cql
JANUSGRAPH_RELATION_DELIMITER: "@"
janusgraph.storage.hostname: jce-cassandra
janusgraph.graph.set-vertex-id: "true"
janusgraph.graph.allow-custom-vid-types: "true"
networks:
- jce-network
restart: unless-stopped
depends_on:
- cassandra

cassandra:
image: cassandra:3
container_name: jce-cassandra
ports:
- "9042:9042"
- "9160:9160"
volumes:
- graph_data:/var/lib/cassandra
networks:
- jce-network

volumes:
graph_data: # Named volume to store JanusGraph data

networks:
jce-network:
version: '3'
services:
janusgraph:
image: janusgraph/janusgraph:1.0.0 # Use the latest JanusGraph image
container_name: jce-janusgraph
ports:
- "8182:8182" # Map the Gremlin server port to the host
environment:
JANUS_PROPS_TEMPLATE: cql
JANUSGRAPH_RELATION_DELIMITER: "@"
janusgraph.storage.hostname: jce-cassandra
janusgraph.graph.set-vertex-id: "true"
janusgraph.graph.allow-custom-vid-types: "true"
networks:
- jce-network
restart: unless-stopped
depends_on:
- cassandra

cassandra:
image: cassandra:3
container_name: jce-cassandra
ports:
- "9042:9042"
- "9160:9160"
volumes:
- graph_data:/var/lib/cassandra
networks:
- jce-network

volumes:
graph_data: # Named volume to store JanusGraph data

networks:
jce-network:
My minimal example Golang code that is not working:
package main

import (
"time"

gremlingo "github.com/apache/tinkerpop/gremlin-go/driver"
)

func main() {
endpoint := "ws://localhost:8182/gremlin"
var remoteConnection *gremlingo.DriverRemoteConnection

remoteConnection, err := gremlingo.NewDriverRemoteConnection(endpoint, func(settings *gremlingo.DriverRemoteConnectionSettings) {
settings.TraversalSource = "g"
settings.KeepAliveInterval = time.Duration(15 * time.Minute)
})
if err != nil {
panic(err)
}

query := `g.V().limit(2)`

result, err := remoteConnection.Submit(query)
if err != nil {
panic(err)
}

resultList, err := result.All()
if err != nil {
panic(err)
}

for _, item := range resultList {
println(item.String())
}

defer remoteConnection.Close()
}
package main

import (
"time"

gremlingo "github.com/apache/tinkerpop/gremlin-go/driver"
)

func main() {
endpoint := "ws://localhost:8182/gremlin"
var remoteConnection *gremlingo.DriverRemoteConnection

remoteConnection, err := gremlingo.NewDriverRemoteConnection(endpoint, func(settings *gremlingo.DriverRemoteConnectionSettings) {
settings.TraversalSource = "g"
settings.KeepAliveInterval = time.Duration(15 * time.Minute)
})
if err != nil {
panic(err)
}

query := `g.V().limit(2)`

result, err := remoteConnection.Submit(query)
if err != nil {
panic(err)
}

resultList, err := result.All()
if err != nil {
panic(err)
}

for _, item := range resultList {
println(item.String())
}

defer remoteConnection.Close()
}
14 replies