@@ -25,14 +25,17 @@ import (
2525 "github.com/apache/tinkerpop/gremlin-go/v3/driver"
2626)
2727
28+ var serverURL = "ws://localhost:8182/gremlin"
29+ var vertexLabel = "connection"
30+
2831func main () {
2932 withRemote ()
3033 withConfigs ()
3134}
3235
3336func withRemote () {
34- // Creating the connection to the server
35- driverRemoteConnection , err := gremlingo .NewDriverRemoteConnection ("ws://localhost:8182/gremlin" )
37+ // Creating the connection to the server
38+ driverRemoteConnection , err := gremlingo .NewDriverRemoteConnection (serverURL )
3639
3740 // Error handling
3841 if err != nil {
@@ -43,22 +46,18 @@ func withRemote() {
4346 // Cleanup
4447 defer driverRemoteConnection .Close ()
4548
46- // Creating the graph traversal
49+ // Creating the graph traversal
4750 g := gremlingo .Traversal_ ().WithRemote (driverRemoteConnection )
4851
49- // Drop existing vertices
50- prom := g .V ().Drop ().Iterate ()
51- <- prom
52-
53- // Simple query to verify connection
54- g .AddV ("connection" ).Iterate ()
55- count , _ := g .V ().HasLabel ("connection" ).Count ().Next ()
56- fmt .Println ("Vertex count:" , * count )
52+ // Simple query to verify connection
53+ g .AddV (vertexLabel ).Iterate ()
54+ count , _ := g .V ().HasLabel (vertexLabel ).Count ().Next ()
55+ fmt .Println ("Vertex count:" , * count )
5756}
5857
5958func withConfigs () {
6059 // Connecting to the server with customized configurations
61- driverRemoteConnection , err := gremlingo .NewDriverRemoteConnection ("ws://localhost:8182/gremlin" ,
60+ driverRemoteConnection , err := gremlingo .NewDriverRemoteConnection (serverURL ,
6261 func (settings * gremlingo.DriverRemoteConnectionSettings ) {
6362 settings .TraversalSource = "g"
6463 settings .NewConnectionThreshold = 4
@@ -75,7 +74,7 @@ func withConfigs() {
7574 defer driverRemoteConnection .Close ()
7675 g := gremlingo .Traversal_ ().WithRemote (driverRemoteConnection )
7776
78- g .AddV ("connection" ).Iterate ()
79- count , _ := g .V ().HasLabel ("connection" ).Count ().Next ()
80- fmt .Println ("Vertex count:" , * count )
81- }
77+ g .AddV (vertexLabel ).Iterate ()
78+ count , _ := g .V ().HasLabel (vertexLabel ).Count ().Next ()
79+ fmt .Println ("Vertex count:" , * count )
80+ }
0 commit comments