A Go package built to communicate with Apache TinkerPop™ Graph computing framework using Gremlin; a graph traversal language used by graph databases such as JanusGraph®, MS Cosmos DB, AWS Neptune, and DataStax® Enterprise Graph.
Here is the main function also provided in the example:
package main
import (
"encoding/json"
"flag"
"fmt"
"go.uber.org/zap"
"github.com/northwesternmutual/grammes"
"github.com/northwesternmutual/grammes/examples/exampleutil"
)
var (
// addr is used for holding the connection IP address.
// for example this could be, "ws://127.0.0.1:8182"
addr string
)
func main() {
flag.StringVar(&addr, "h", "", "Connection IP")
flag.Parse()
logger := exampleutil.SetupLogger()
defer logger.Sync()
if addr == "" {
logger.Fatal("No host address provided. Please run: go run main.go -h <host address>")
return
}
// Create a new Grammes client with a standard websocket.
client, err := grammes.DialWithWebSocket(addr)
if err != nil {
logger.Fatal("Couldn't create client", zap.Error(err))
}
defer client.DropAll()
// Create a graph traversal.
g := grammes.Traversal()
// Use the traversal to add a vertex.
responses, err := client.ExecuteQuery(g.AddV("Intuit.cloud.monitoring.topology"))
if err != nil {
logger.Fatal("Error querying server", zap.Error(err))
}
responses, err = client.ExecuteQuery(g.V())
if err != nil {
logger.Fatal("Error querying server", zap.Error(err))
}
// Log the response from the Gremlin server.
// This will end up being a raw JSON of a Vertex.
for _, res := range responses {
var result map[string]interface{}
err := json.Unmarshal([]byte(res), &result)
if err != nil {
fmt.Println(err)
}
fmt.Println(result)
}
}
Is this supposed to only connect locally, or in tandem with gremlin console?
When I try to connect to Neptune using the example main.go function:
the neptune ip / dns is the cluster endpoint provided when creating a neptune cluster on aws.
I get the following:
what am I doing wrong.
Here is the main function also provided in the example:
Is this supposed to only connect locally, or in tandem with gremlin console?