diff --git a/bin/run-examples.sh b/bin/run-examples.sh new file mode 100755 index 00000000000..5548404ec86 --- /dev/null +++ b/bin/run-examples.sh @@ -0,0 +1,119 @@ +#!/bin/bash + +#Licensed to the Apache Software Foundation (ASF) under one +#or more contributor license agreements. See the NOTICE file +#distributed with this work for additional information +#regarding copyright ownership. The ASF licenses this file +#to you under the Apache License, Version 2.0 (the +#"License"); you may not use this file except in compliance +#with the License. You may obtain a copy of the License at +# +#http://www.apache.org/licenses/LICENSE-2.0 +# +#Unless required by applicable law or agreed to in writing, +#software distributed under the License is distributed on an +#"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +#KIND, either express or implied. See the License for the +#specific language governing permissions and limitations +#under the License. + +function cleanup { + if [ -n "$(docker ps -q -f name=glv-examples)" ] + then + echo -n "Shutting down container: " + docker stop glv-examples + fi + if [ -n "$(docker ps -q -f name=glv-examples-modern)" ] + then + echo -n "Shutting down container: " + docker stop glv-examples-modern + fi +} +trap cleanup EXIT + +open -a Docker +docker pull tinkerpop/gremlin-server +docker run -d --rm -p 8182:8182 --name glv-examples --health-cmd="curl -f http://localhost:8182/ || exit 1" --health-interval=5s --health-timeout=3s tinkerpop/gremlin-server + +echo +echo "Not having docker open initially may cause an error loop. If so, simply restart this script." +echo -n "Starting Gremlin server on port 8182..." +until docker inspect --format '{{.State.Health.Status}}' glv-examples | grep -q "healthy"; do + echo -n "." + sleep 1 +done +echo + +cd ../gremlin-driver/src/main/java/examples || exit +mvn clean install + +echo +echo "Running Java examples" +java -cp target/run-examples-shaded.jar examples.Connections +java -cp target/run-examples-shaded.jar examples.BasicGremlin +cd ../../../../.. || exit + +echo +echo "Running python examples:" +python3 gremlin-python/src/main/python/examples/connections.py +python3 gremlin-python/src/main/python/examples/basic_gremlin.py + +echo +echo "Running JavaScript examples:" +npm install --prefix gremlin-javascript/examples +node gremlin-javascript/examples/connections.js +node gremlin-javascript/examples/basic-gremlin.js + +echo +echo "Running .NET examples:" +dotnet run --project gremlin-dotnet/Examples/Connections +dotnet run --project gremlin-dotnet/Examples/BasicGremlin + +echo +echo "Running Go examples:" +cd gremlin-go/examples || exit +go run connections.go +go run basic_gremlin.go +cd ../.. || exit + +echo +echo -n "Shutting down container: " +docker stop glv-examples + +echo +docker run -d --rm -p 8182:8182 --name glv-examples-modern --health-cmd="curl -f http://localhost:8182/ || exit 1" --health-interval=5s --health-timeout=3s tinkerpop/gremlin-server conf/gremlin-server-modern.yaml +echo -n "Starting Modern server on port 8182..." +until docker inspect --format '{{.State.Health.Status}}' glv-examples-modern | grep -q "healthy"; do + echo -n "." + sleep 1 +done +echo + +echo +echo "Running Java traversals" +cd gremlin-driver/src/main/java/examples || exit +java -cp target/run-examples-shaded.jar examples.ModernTraversals +cd ../../../../.. || exit + +echo +echo "Running python traversals:" +python3 gremlin-python/src/main/python/examples/modern_traversals.py + +echo +echo "Running JavaScript traversals:" +npm install --prefix gremlin-javascript/examples +node gremlin-javascript/examples/modern-traversals.js + +echo +echo "Running .NET traversals:" +dotnet run --project gremlin-dotnet/Examples/ModernTraversals + +echo +echo "Running Go traversals:" +cd gremlin-go/examples || exit +go run modern_traversals.go +cd ../.. || exit + +echo +echo -n "Shutting down container: " +docker stop glv-examples-modern diff --git a/docs/src/dev/developer/release.asciidoc b/docs/src/dev/developer/release.asciidoc index e54ad09d53d..a55f0d13156 100644 --- a/docs/src/dev/developer/release.asciidoc +++ b/docs/src/dev/developer/release.asciidoc @@ -120,6 +120,7 @@ during this period. .. Run the full integration test suite: `docker/build.sh -t -i -n` .. Build and test the Docker images: `mvn clean install -pl gremlin-server,gremlin-console -DdockerImages` .. Ensure that the Gremlin.Net.Template gets packaged successfully: `mvn clean install -pl :gremlin-dotnet-source -Dnuget` +.. Ensure that the GLV examples are compiling and running successfully: `bin/run-examples.sh` .. Deploy a final SNAPSHOT to the Apache snapshot repository for Java. .. Review LICENSE and NOTICE files to make sure that no <>. .. Review javadoc filters on the "Core API" docs to be sure nothing needs to change. diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc index fbef16744b5..50dca672229 100644 --- a/docs/src/reference/gremlin-variants.asciidoc +++ b/docs/src/reference/gremlin-variants.asciidoc @@ -527,14 +527,37 @@ that can be used to fulfill the `gremlingo.Set` interface if desired. [[gremlin-go-examples]] === Application Examples -The TinkerPop source code contains a simple Go script that shows a basic example of how gremlin-go works. It -can be found in GitHub link:https://github.com/apache/tinkerpop/tree/x.y.z/gremlin-go/example/example.go[here] -and is designed to work best with a running <> configured with the default -`conf/gremlin-server.yaml` file as included with the standard release packaging. +The TinkerPop source code contains some sample applications that demonstrate the basics of Gremlin-Go. They +can be found in GitHub link:https://github.com/apache/tinkerpop/tree/x.y.z/gremlin-go/examples/[here] +and are designed to connect to a running <> configured with the +`conf/gremlin-server.yaml` and `conf/gremlin-server-modern.yaml` files as included with the standard release packaging. +To run the examples, first download an image of Gremlin Server from Docker Hub: [source,shell] ---- -go run example.go +docker pull tinkerpop/gremlin-server +---- + +The remote connection and basic Gremlin examples can be run on a clean server, which uses the default configuration file +`conf/gremlin-server.yaml`. To start a clean server, launch a new container with `docker run`: +[source,shell] +---- +docker run -d -p 8182:8182 tinkerpop/gremlin-server +---- + +The traversal examples should be run on a server configured to start with the Modern toy graph, using `conf/gremlin-server-modern.yaml`. +To start a server with the Modern graph preloaded, launch a new container with `docker run`: +[source,shell] +---- +docker run -d -p 8182:8182 tinkerpop/gremlin-server conf/gremlin-server-modern.yaml +---- + +Each example can now be run with the following commands: +[source,shell] +---- +go run connections.go +go run basic_gremlin.go +go run modern_traversals.go ---- [[gremlin-groovy]] @@ -1201,8 +1224,8 @@ Connection Pool Status (size=1 max=5 min=1 toCreate=0 bin=0) anchor:java-application-examples[] anchor:gremlin-archetypes[] -[[gremlin-java-examples]] -=== Application Examples +[[gremlin-java-archetypes]] +=== Application Archetypes The available link:https://maven.apache.org/guides/introduction/introduction-to-archetypes.html[Maven archetypes] are as follows: @@ -1224,6 +1247,24 @@ This command will generate a new Maven project in a directory called "app" with `com.my`. Please see the `README.asciidoc` in the root of each generated project for information on how to build and execute it. +[[gremlin-java-examples]] +=== Application Examples + +The TinkerPop source code contains some sample applications that demonstrate the basics of Gremlin-Java. They +can be found in GitHub link:https://github.com/apache/tinkerpop/tree/x.y.z/gremlin-driver/src/main/java/examples/[here]. + +The remote connection examples in particular are designed to connect to a running <> +configured with the `conf/gremlin-server.yaml` file as included with the standard release packaging. + +To do so, download an image of Gremlin Server from Docker Hub, then launch a new container with `docker run`: +[source,shell] +---- +docker pull tinkerpop/gremlin-server +docker run -d -p 8182:8182 tinkerpop/gremlin-server +---- + +All examples can then be run using your IDE of choice. + [[gremlin-javascript]] == Gremlin-JavaScript @@ -1629,6 +1670,48 @@ the possibility of `null`. no `Graph` instance to deserialize a result into on the client-side. A workaround is to replace the step with `aggregate(local)` and then convert those results to something the client can use locally. +[[gremlin-javascript-examples]] +=== Application Examples + +The TinkerPop source code contains some sample applications that demonstrate the basics of Gremlin-JavaScript. They +can be found in GitHub link:https://github.com/apache/tinkerpop/tree/x.y.z/gremlin-javascript/examples/[here] +and are designed to connect to a running <> configured with the +`conf/gremlin-server.yaml` and `conf/gremlin-server-modern.yaml` files as included with the standard release packaging. + +To run the examples, first download an image of Gremlin Server from Docker Hub: +[source,shell] +---- +docker pull tinkerpop/gremlin-server +---- + +The remote connection and basic Gremlin examples can be run on a clean server, which uses the default configuration file +`conf/gremlin-server.yaml`. To start a clean server, launch a new container with `docker run`: +[source,shell] +---- +docker run -d -p 8182:8182 tinkerpop/gremlin-server +---- + +The traversal examples should be run on a server configured to start with the Modern toy graph, using `conf/gremlin-server-modern.yaml`. +To start a server with the Modern graph preloaded, launch a new container with `docker run`: +[source,shell] +---- +docker run -d -p 8182:8182 tinkerpop/gremlin-server conf/gremlin-server-modern.yaml +---- + +Make sure to install all necessary packages: +[source,shell] +---- +npm install +---- + +Each example can now be run with the following commands: +[source,shell] +---- +node connections.js +node basic-gremlin.js +node modern-traversals.js +---- + anchor:gremlin-DotNet[] [[gremlin-dotnet]] == Gremlin.Net @@ -1967,8 +2050,8 @@ no `Graph` instance to deserialize a result into on the client-side. A workaroun anchor:gremlin-dotnet-template[] anchor:dotnet-application-examples[] anchor:gremlin-net-examples[] -[[gremlin-dotnet-examples]] -=== Application Examples +[[gremlin-dotnet-startup]] +=== Getting Started This link:https://docs.microsoft.com/dotnet/core/tools/custom-templates[dotnet template] helps getting started with <>. It creates a new C# console project that shows how to connect to a @@ -1988,6 +2071,40 @@ Specify the output directory for the new project which will then also be used as [source,shell] dotnet new gremlin -o MyFirstGremlinProject +[[gremlin-dotnet-examples]] +=== Application Examples + +The TinkerPop source code contains some sample applications that demonstrate the basics of Gremlin-Dotnet. They +can be found in GitHub link:https://github.com/apache/tinkerpop/tree/x.y.z/gremlin-dotnet/Examples/[here] +and are designed to connect to a running <> configured with the +`conf/gremlin-server.yaml` and `conf/gremlin-server-modern.yaml` files as included with the standard release packaging. + +To run the examples, first download an image of Gremlin Server from Docker Hub: +[source,shell] +---- +docker pull tinkerpop/gremlin-server +---- + +The remote connection and basic Gremlin examples can be run on a clean server, which uses the default configuration file +`conf/gremlin-server.yaml`. To start a clean server, launch a new container with `docker run`: +[source,shell] +---- +docker run -d -p 8182:8182 tinkerpop/gremlin-server +---- + +The traversal examples should be run on a server configured to start with the Modern toy graph, using `conf/gremlin-server-modern.yaml`. +To start a server with the Modern graph preloaded, launch a new container with `docker run`: +[source,shell] +---- +docker run -d -p 8182:8182 tinkerpop/gremlin-server conf/gremlin-server-modern.yaml +---- + +Each example can now be run with the following command in their respective project directories: +[source,shell] +---- +dotnet run +---- + [[gremlin-python]] == Gremlin-Python @@ -2527,14 +2644,35 @@ async def run_in_thread(): [[gremlin-python-examples]] === Application Examples -The TinkerPop source code contains a simple Python script that shows a basic example of how gremlinpython works. It -can be found in GitHub link:https://github.com/apache/tinkerpop/tree/x.y.z/gremlin-python/src/main/python/example.py[here] -and is designed to work best with a running <> configured with the default -`conf/gremlin-server.yaml` file as included with the standard release packaging. +The TinkerPop source code contains some sample applications that demonstrate the basics of Gremlin-Python. They +can be found in GitHub link:https://github.com/apache/tinkerpop/tree/x.y.z/gremlin-python/src/main/python/examples/[here] +and are designed to connect to a running <> configured with the +`conf/gremlin-server.yaml` and `conf/gremlin-server-modern.yaml` files as included with the standard release packaging. +To run the examples, first download an image of Gremlin Server from Docker Hub: [source,shell] ---- -pip install gremlinpython -pip install aiohttp -python example.py +docker pull tinkerpop/gremlin-server +---- + +The remote connection and basic Gremlin examples can be run on a clean server, which uses the default configuration file +`conf/gremlin-server.yaml`. To start a clean server, launch a new container with `docker run`: +[source,shell] +---- +docker run -d -p 8182:8182 tinkerpop/gremlin-server +---- + +The traversal examples should be run on a server configured to start with the Modern toy graph, using `conf/gremlin-server-modern.yaml`. +To start a server with the Modern graph preloaded, launch a new container with `docker run`: +[source,shell] +---- +docker run -d -p 8182:8182 tinkerpop/gremlin-server conf/gremlin-server-modern.yaml +---- + +Each example can now be run with the following commands: +[source,shell] +---- +python connections.py +python basic_gremlin.py +python modern_traversals.py ---- diff --git a/gremlin-dotnet/Examples/BasicGremlin/BasicGremlin.cs b/gremlin-dotnet/Examples/BasicGremlin/BasicGremlin.cs new file mode 100644 index 00000000000..91820bfe095 --- /dev/null +++ b/gremlin-dotnet/Examples/BasicGremlin/BasicGremlin.cs @@ -0,0 +1,54 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +using Gremlin.Net.Driver; +using Gremlin.Net.Driver.Remote; +using static Gremlin.Net.Process.Traversal.AnonymousTraversalSource; + +public class BasicGremlinExample +{ + static async Task Main() + { + var server = new GremlinServer("localhost", 8182); + using var remoteConnection = new DriverRemoteConnection(new GremlinClient(server), "g"); + var g = Traversal().WithRemote(remoteConnection); + + // Basic Gremlin: adding and retrieving data + var v1 = g.AddV("person").Property("name", "marko").Next(); + var v2 = g.AddV("person").Property("name", "stephen").Next(); + var v3 = g.AddV("person").Property("name", "vadas").Next(); + + // Be sure to use a terminating step like Next() or Iterate() so that the traversal "executes" + // Iterate() does not return any data and is used to just generate side-effects (i.e. write data to the database) + g.V(v1).AddE("knows").To(v2).Property("weight", 0.75).Iterate(); + g.V(v1).AddE("knows").To(v3).Property("weight", 0.75).Iterate(); + + // Retrieve the data from the "marko" vertex + var marko = await g.V().Has("person", "name", "marko").Values("name").Promise(t => t.Next()); + Console.WriteLine("name: " + marko); + + // Find the "marko" vertex and then traverse to the people he "knows" and return their data + var peopleMarkoKnows = await g.V().Has("person", "name", "marko").Out("knows").Values("name").Promise(t => t.ToList()); + foreach (var person in peopleMarkoKnows) + { + Console.WriteLine("marko knows " + person); + } + } +} + diff --git a/gremlin-dotnet/Examples/BasicGremlin/BasicGremlin.csproj b/gremlin-dotnet/Examples/BasicGremlin/BasicGremlin.csproj new file mode 100644 index 00000000000..6fe7a3b6333 --- /dev/null +++ b/gremlin-dotnet/Examples/BasicGremlin/BasicGremlin.csproj @@ -0,0 +1,30 @@ + + + + + + Exe + net7.0 + enable + enable + + + + + + diff --git a/gremlin-dotnet/Examples/Connections/Connections.cs b/gremlin-dotnet/Examples/Connections/Connections.cs new file mode 100644 index 00000000000..26490f750b2 --- /dev/null +++ b/gremlin-dotnet/Examples/Connections/Connections.cs @@ -0,0 +1,74 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +using Gremlin.Net.Driver; +using Gremlin.Net.Driver.Remote; +using Gremlin.Net.Structure.IO.GraphSON; +using static Gremlin.Net.Process.Traversal.AnonymousTraversalSource; + +public class ConnectionExample +{ + static void Main() + { + withRemote(); + withConf(); + withSerializer(); + } + + // Connecting to the server + static void withRemote() + { + var server = new GremlinServer("localhost", 8182); + using var remoteConnection = new DriverRemoteConnection(new GremlinClient(server), "g"); + var g = Traversal().WithRemote(remoteConnection); + + // Drop existing vertices + g.V().Drop().Iterate(); + + // Simple query to verify connection + var v = g.AddV().Iterate(); + var count = g.V().Count().Next(); + Console.WriteLine("Vertex count: " + count); + } + + // Connecting to the server with customized configurations + static void withConf() + { + using var remoteConnection = new DriverRemoteConnection(new GremlinClient( + new GremlinServer(hostname: "localhost", port: 8182, enableSsl: false, username: "", password: "")), "g"); + var g = Traversal().WithRemote(remoteConnection); + + var v = g.AddV().Iterate(); + var count = g.V().Count().Next(); + Console.WriteLine("Vertex count: " + count); + } + + // Specifying a serializer + static void withSerializer() + { + var server = new GremlinServer("localhost", 8182); + var client = new GremlinClient(server, new GraphSON3MessageSerializer()); + using var remoteConnection = new DriverRemoteConnection(client, "g"); + var g = Traversal().WithRemote(remoteConnection); + + var v = g.AddV().Iterate(); + var count = g.V().Count().Next(); + Console.WriteLine("Vertex count: " + count); + } +} diff --git a/gremlin-dotnet/Examples/Connections/Connections.csproj b/gremlin-dotnet/Examples/Connections/Connections.csproj new file mode 100644 index 00000000000..6fe7a3b6333 --- /dev/null +++ b/gremlin-dotnet/Examples/Connections/Connections.csproj @@ -0,0 +1,30 @@ + + + + + + Exe + net7.0 + enable + enable + + + + + + diff --git a/gremlin-dotnet/Examples/Examples.sln b/gremlin-dotnet/Examples/Examples.sln new file mode 100644 index 00000000000..963bb259f6e --- /dev/null +++ b/gremlin-dotnet/Examples/Examples.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 25.0.1706.4 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Connections", "Connections\Connections.csproj", "{9E201BDD-911A-4671-A12E-B7400E9FA5DB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicGremlin", "BasicGremlin\BasicGremlin.csproj", "{535D7393-6115-4BEF-A344-E7DE3A891098}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernTraversals", "ModernTraversals\ModernTraversals.csproj", "{F3D3A764-F72A-4F63-9C23-D998BA61CAD4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9E201BDD-911A-4671-A12E-B7400E9FA5DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E201BDD-911A-4671-A12E-B7400E9FA5DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E201BDD-911A-4671-A12E-B7400E9FA5DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E201BDD-911A-4671-A12E-B7400E9FA5DB}.Release|Any CPU.Build.0 = Release|Any CPU + {535D7393-6115-4BEF-A344-E7DE3A891098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {535D7393-6115-4BEF-A344-E7DE3A891098}.Debug|Any CPU.Build.0 = Debug|Any CPU + {535D7393-6115-4BEF-A344-E7DE3A891098}.Release|Any CPU.ActiveCfg = Release|Any CPU + {535D7393-6115-4BEF-A344-E7DE3A891098}.Release|Any CPU.Build.0 = Release|Any CPU + {F3D3A764-F72A-4F63-9C23-D998BA61CAD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F3D3A764-F72A-4F63-9C23-D998BA61CAD4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F3D3A764-F72A-4F63-9C23-D998BA61CAD4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F3D3A764-F72A-4F63-9C23-D998BA61CAD4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {042DF872-50CB-4F95-9CDB-117540F4DF29} + EndGlobalSection +EndGlobal diff --git a/gremlin-dotnet/Examples/ModernTraversals/ModernTraversals.cs b/gremlin-dotnet/Examples/ModernTraversals/ModernTraversals.cs new file mode 100644 index 00000000000..fab70735301 --- /dev/null +++ b/gremlin-dotnet/Examples/ModernTraversals/ModernTraversals.cs @@ -0,0 +1,71 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +using Gremlin.Net.Driver; +using Gremlin.Net.Driver.Remote; +using Gremlin.Net.Process.Traversal; +using static Gremlin.Net.Process.Traversal.AnonymousTraversalSource; +using static Gremlin.Net.Process.Traversal.__; +using static Gremlin.Net.Process.Traversal.P; + +public class ModernTraversalExample +{ + static void Main() + { + var server = new GremlinServer("localhost", 8182); + using var remoteConnection = new DriverRemoteConnection(new GremlinClient(server), "g"); + var g = Traversal().WithRemote(remoteConnection); + + /* + This example requires the Modern toy graph to be preloaded upon launching the Gremlin server. + For details, see https://tinkerpop.apache.org/docs/current/reference/#gremlin-server-docker-image and use + conf/gremlin-server-modern.yaml. + */ + var e1 = g.V(1).BothE().ToList(); // (1) + var e2 = g.V(1).BothE().Where(OtherV().HasId(2)).ToList(); // (2) + var v1 = g.V(1).Next(); + var v2 = g.V(2).Next(); + var e3 = g.V(v1).BothE().Where(OtherV().Is(v2)).ToList(); // (3) + var e4 = g.V(v1).OutE().Where(InV().Is(v2)).ToList(); // (4) + var e5 = g.V(1).OutE().Where(InV().Has(T.Id, Within(2, 3))).ToList(); // (5) + var e6 = g.V(1).Out().Where(__.In().HasId(6)).ToList(); // (6) + + Console.WriteLine(string.Join(", ", e1)); + Console.WriteLine(string.Join(", ", e2)); + Console.WriteLine(string.Join(", ", e3)); + Console.WriteLine(string.Join(", ", e4)); + Console.WriteLine(string.Join(", ", e5)); + Console.WriteLine(string.Join(", ", e6)); + + /* + 1. There are three edges from the vertex with the identifier of "1". + 2. Filter those three edges using the Where()-step using the identifier of the vertex returned by OtherV() to + ensure it matches on the vertex of concern, which is the one with an identifier of "2". + 3. Note that the same traversal will work if there are actual Vertex instances rather than just vertex + identifiers. + 4. The vertex with identifier "1" has all outgoing edges, so it would also be acceptable to use the directional + steps of OutE() and InV() since the schema allows it. + 5. There is also no problem with filtering the terminating side of the traversal on multiple vertices, in this + case, vertices with identifiers "2" and "3". + 6. There’s no reason why the same pattern of exclusion used for edges with Where() can’t work for a vertex + + between two vertices. + */ + } +} \ No newline at end of file diff --git a/gremlin-dotnet/Examples/ModernTraversals/ModernTraversals.csproj b/gremlin-dotnet/Examples/ModernTraversals/ModernTraversals.csproj new file mode 100644 index 00000000000..31dd1928968 --- /dev/null +++ b/gremlin-dotnet/Examples/ModernTraversals/ModernTraversals.csproj @@ -0,0 +1,30 @@ + + + + + + Exe + net7.0 + enable + enable + + + + + + diff --git a/gremlin-driver/pom.xml b/gremlin-driver/pom.xml index 83d1fdf0632..421b5a93fcb 100644 --- a/gremlin-driver/pom.xml +++ b/gremlin-driver/pom.xml @@ -265,6 +265,15 @@ limitations under the License. + + org.apache.maven.plugins + maven-compiler-plugin + + + examples/** + + + diff --git a/gremlin-driver/src/main/java/examples/BasicGremlin.java b/gremlin-driver/src/main/java/examples/BasicGremlin.java new file mode 100644 index 00000000000..a5075d46061 --- /dev/null +++ b/gremlin-driver/src/main/java/examples/BasicGremlin.java @@ -0,0 +1,56 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +package examples; + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; + +import java.util.List; + +import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal; + +public class BasicGremlin { + public static void main(String[] args) { + Graph graph = TinkerGraph.open(); + GraphTraversalSource g = traversal().withEmbedded(graph); + + // Basic Gremlin: adding and retrieving data + Vertex v1 = g.addV("person").property("name","marko").next(); + Vertex v2 = g.addV("person").property("name","stephen").next(); + Vertex v3 = g.addV("person").property("name","vadas").next(); + + // Be sure to use a terminating step like next() or iterate() so that the traversal "executes" + // Iterate() does not return any data and is used to just generate side-effects (i.e. write data to the database) + g.V(v1).addE("knows").to(v2).property("weight",0.75).iterate(); + g.V(v1).addE("knows").to(v3).property("weight",0.75).iterate(); + + // Retrieve the data from the "marko" vertex + Object marko = g.V().has("person","name","marko").values("name").next(); + System.out.println("name: " + marko); + + // Find the "marko" vertex and then traverse to the people he "knows" and return their data + List peopleMarkoKnows = g.V().has("person","name","marko").out("knows").values("name").toList(); + for (Object person : peopleMarkoKnows) { + System.out.println("marko knows " + person); + } + } +} diff --git a/gremlin-driver/src/main/java/examples/Connections.java b/gremlin-driver/src/main/java/examples/Connections.java new file mode 100644 index 00000000000..458d5c8fd53 --- /dev/null +++ b/gremlin-driver/src/main/java/examples/Connections.java @@ -0,0 +1,116 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +package examples; + +import org.apache.tinkerpop.gremlin.driver.Channelizer; +import org.apache.tinkerpop.gremlin.driver.Client; +import org.apache.tinkerpop.gremlin.driver.Cluster; +import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.structure.io.AbstractIoRegistry; +import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; +import org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; +import org.apache.tinkerpop.gremlin.util.MessageSerializer; +import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV1; + +import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal; + +public class Connections { + public static void main(String[] args) throws Exception { + withEmbedded(); + withRemote(); + withCluster(); + withSerializer(); + } + + // Creating an embedded graph + private static void withEmbedded() throws Exception { + Graph graph = TinkerGraph.open(); + GraphTraversalSource g = traversal().withEmbedded(graph); + + g.addV().iterate(); + long count = g.V().count().next(); + System.out.println("Vertex count: " + count); + + g.close(); + } + + // Connecting to the server + private static void withRemote() throws Exception { + Cluster cluster = Cluster.build("localhost").port(8182).create(); + GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(cluster, "g")); + + // Drop existing vertices + g.V().drop().iterate(); + + // Simple query to verify connection + g.addV().iterate(); + long count = g.V().count().next(); + System.out.println("Vertex count: " + count); + + // Cleanup + cluster.close(); + g.close(); + } + + // Connecting and customizing configurations with a cluster + // See reference/#gremlin-java-configuration for full list of configurations + private static void withCluster() throws Exception { + Cluster cluster = Cluster.build("localhost"). + channelizer(Channelizer.WebSocketChannelizer.class). + keepAliveInterval(180000). + maxConnectionPoolSize(8). + path("/gremlin"). + port(8182). + serializer(new GraphBinaryMessageSerializerV1()). + create(); + GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(cluster, "g")); + + g.addV().iterate(); + long count = g.V().count().next(); + System.out.println("Vertex count: " + count); + + cluster.close(); + g.close(); + } + + // Connecting and specifying a serializer + private static void withSerializer() throws Exception { + IoRegistry registry = new FakeIoRegistry(); // an IoRegistry instance exposed by a specific graph provider + TypeSerializerRegistry typeSerializerRegistry = TypeSerializerRegistry.build().addRegistry(registry).create(); + MessageSerializer serializer = new GraphBinaryMessageSerializerV1(typeSerializerRegistry); + Cluster cluster = Cluster.build("localhost"). + serializer(serializer). + create(); + Client client = cluster.connect(); + GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(client, "g")); + + g.addV().iterate(); + long count = g.V().count().next(); + System.out.println("Vertex count: " + count); + + cluster.close(); + g.close(); + } + + public static class FakeIoRegistry extends AbstractIoRegistry {} +} diff --git a/gremlin-driver/src/main/java/examples/ModernTraversals.java b/gremlin-driver/src/main/java/examples/ModernTraversals.java new file mode 100644 index 00000000000..c67b6daeb27 --- /dev/null +++ b/gremlin-driver/src/main/java/examples/ModernTraversals.java @@ -0,0 +1,71 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +package examples; + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.Edge; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory; + +import java.util.List; + +import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal; +import static org.apache.tinkerpop.gremlin.process.traversal.P.within; +import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.*; +import static org.apache.tinkerpop.gremlin.structure.T.id; + +public class ModernTraversals { + public static void main(String[] args) { + // Performs basic traversals on the Modern toy graph which can be created using TinkerFactory + Graph modern = TinkerFactory.createModern(); + GraphTraversalSource g = traversal().withEmbedded(modern); + + List e1 = g.V(1).bothE().toList(); // (1) + List e2 = g.V(1).bothE().where(otherV().hasId(2)).toList(); // (2) + Vertex v1 = g.V(1).next(); + Vertex v2 = g.V(2).next(); + List e3 = g.V(v1).bothE().where(otherV().is(v2)).toList(); // (3) + List e4 = g.V(v1).outE().where(inV().is(v2)).toList(); // (4) + List e5 = g.V(1).outE().where(inV().has(id, within(2,3))).toList(); // (5) + List e6 = g.V(1).out().where(in().hasId(6)).toList(); // (6) + + System.out.println("1: " + e1.toString()); + System.out.println("2: " + e2.toString()); + System.out.println("3: " + e3.toString()); + System.out.println("4: " + e4.toString()); + System.out.println("5: " + e5.toString()); + System.out.println("6: " + e6.toString()); + + /* + 1. There are three edges from the vertex with the identifier of "1". + 2. Filter those three edges using the where()-step using the identifier of the vertex returned by otherV() to + ensure it matches on the vertex of concern, which is the one with an identifier of "2". + 3. Note that the same traversal will work if there are actual Vertex instances rather than just vertex + identifiers. + 4. The vertex with identifier "1" has all outgoing edges, so it would also be acceptable to use the directional + steps of outE() and inV() since the schema allows it. + 5. There is also no problem with filtering the terminating side of the traversal on multiple vertices, in this + case, vertices with identifiers "2" and "3". + 6. There’s no reason why the same pattern of exclusion used for edges with where() can’t work for a vertex + between two vertices. + */ + } +} diff --git a/gremlin-driver/src/main/java/examples/pom.xml b/gremlin-driver/src/main/java/examples/pom.xml new file mode 100644 index 00000000000..85417eff1dc --- /dev/null +++ b/gremlin-driver/src/main/java/examples/pom.xml @@ -0,0 +1,91 @@ + + + 4.0.0 + + org.apache.tinkerpop + run-examples + 3.7.1 + + + UTF-8 + ${project.version} + + + + + org.apache.tinkerpop + gremlin-core + ${project.version} + + + org.apache.tinkerpop + gremlin-driver + ${project.version} + + + org.apache.tinkerpop + tinkergraph-gremlin + ${project.version} + + + + + . + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-shade-plugin + 3.4.1 + + + package + + shade + + + run-examples-shaded + false + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + + + + \ No newline at end of file diff --git a/gremlin-go/example/go.sum b/gremlin-go/example/go.sum deleted file mode 100644 index 4a83d5aef46..00000000000 --- a/gremlin-go/example/go.sum +++ /dev/null @@ -1,315 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/apache/tinkerpop/gremlin-go/v3 v3.6.1-rc2 h1:3lQ4NUwq+9FzljbOj9A4j0DtTJXHRWeyffk/fhNmR5w= -github.com/apache/tinkerpop/gremlin-go/v3 v3.6.1-rc2/go.mod h1:6LYD7pUNUiMEUTyAKDA30e2W2luaubMI667CgR2MGa0= -github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cucumber/gherkin-go/v19 v19.0.3/go.mod h1:jY/NP6jUtRSArQQJ5h1FXOUgk5fZK24qtE7vKi776Vw= -github.com/cucumber/godog v0.12.5/go.mod h1:u6SD7IXC49dLpPN35kal0oYEjsXZWee4pW6Tm9t5pIc= -github.com/cucumber/messages-go/v16 v16.0.0/go.mod h1:EJcyR5Mm5ZuDsKJnT2N9KRnBK30BGjtYotDKpwQ0v6g= -github.com/cucumber/messages-go/v16 v16.0.1/go.mod h1:EJcyR5Mm5ZuDsKJnT2N9KRnBK30BGjtYotDKpwQ0v6g= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= -github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-memdb v1.3.0/go.mod h1:Mluclgwib3R93Hk5fxEfiRhB+6Dar64wWh71LpNSe3g= -github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= -github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= -github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= -github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= -github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= -github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/nicksnyder/go-i18n/v2 v2.1.2 h1:QHYxcUJnGHBaq7XbvgunmZ2Pn0focXFqTD61CkH146c= -github.com/nicksnyder/go-i18n/v2 v2.1.2/go.mod h1:d++QJC9ZVf7pa48qrsRWhMJ5pSHIPmS3OLqK1niyLxs= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= -gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/gremlin-go/examples/basic_gremlin.go b/gremlin-go/examples/basic_gremlin.go new file mode 100644 index 00000000000..0ab2b1117fd --- /dev/null +++ b/gremlin-go/examples/basic_gremlin.go @@ -0,0 +1,69 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +package main + +import ( + "fmt" + + "github.com/apache/tinkerpop/gremlin-go/v3/driver" +) + +func main() { + driverRemoteConnection, err := gremlingo.NewDriverRemoteConnection("ws://localhost:8182/gremlin") + if err != nil { + fmt.Println(err) + return + } + defer driverRemoteConnection.Close() + g := gremlingo.Traversal_().WithRemote(driverRemoteConnection) + + // Basic Gremlin: adding and retrieving data + v1, err := g.AddV("person").Property("name", "marko").Next() + v2, err := g.AddV("person").Property("name", "stephen").Next() + v3, err := g.AddV("person").Property("name", "vadas").Next() + v1Vertex, err := v1.GetVertex() + v2Vertex, err := v2.GetVertex() + v3Vertex, err := v3.GetVertex() + + // Be sure to use a terminating step like Next() or Iterate() so that the traversal "executes" + // Iterate() does not return any data and is used to just generate side-effects (i.e. write data to the database) + promise := g.V(v1Vertex).AddE("knows").To(v2Vertex).Property("weight", 0.75).Iterate() + err = <-promise + if err != nil { + fmt.Println(err) + return + } + promise = g.V(v1Vertex).AddE("knows").To(v3Vertex).Property("weight", 0.75).Iterate() + err = <-promise + if err != nil { + fmt.Println(err) + return + } + + // Retrieve the data from the "marko" vertex + marko, err := g.V().Has("person", "name", "marko").Values("name").Next() + fmt.Println("name:", marko.GetString()) + + // Find the "marko" vertex and then traverse to the people he "knows" and return their data + peopleMarkoKnows, err := g.V().Has("person", "name", "marko").Out("knows").Values("name").ToList() + for _, person := range peopleMarkoKnows { + fmt.Println("marko knows", person.GetString()) + } +} \ No newline at end of file diff --git a/gremlin-go/example/example.go b/gremlin-go/examples/connections.go similarity index 56% rename from gremlin-go/example/example.go rename to gremlin-go/examples/connections.go index ab99ac2e1a1..3e1f1de174d 100644 --- a/gremlin-go/example/example.go +++ b/gremlin-go/examples/connections.go @@ -21,38 +21,61 @@ package main import ( "fmt" - gremlingo "github.com/apache/tinkerpop/gremlin-go/driver" + "github.com/apache/tinkerpop/gremlin-go/v3/driver" ) -// syntactic sugar -var __ = gremlingo.T__ -var gt = gremlingo.P.Gt -var order = gremlingo.Order - func main() { - // Creating the connection to the server. - driverRemoteConnection, err := gremlingo.NewDriverRemoteConnection("ws://localhost:8182/gremlin", - func(settings *gremlingo.DriverRemoteConnectionSettings) { - settings.TraversalSource = "gmodern" - }) + withRemote() + withConfigs() +} + +func withRemote() { + // Creating the connection to the server + driverRemoteConnection, err := gremlingo.NewDriverRemoteConnection("ws://localhost:8182/gremlin") + + // Error handling if err != nil { fmt.Println(err) return } + // Cleanup defer driverRemoteConnection.Close() - // Creating graph traversal + // Creating the graph traversal g := gremlingo.Traversal_().WithRemote(driverRemoteConnection) - // Perform traversal - result, err := g.V().HasLabel("person").Has("age", __.Is(gt(28))).Order().By("age", order.Desc).Values("name").ToList() + // Drop existing vertices + prom := g.V().Drop().Iterate() + <-prom + + // Simple query to verify connection + g.AddV().Iterate() + count, _ := g.V().Count().Next() + fmt.Println("Vertex count:", *count) +} + +func withConfigs() { + // Connecting to the server with customized configurations + driverRemoteConnection, err := gremlingo.NewDriverRemoteConnection("ws://localhost:8182/gremlin", + func(settings *gremlingo.DriverRemoteConnectionSettings) { + settings.TraversalSource = "g" + settings.NewConnectionThreshold = 4 + settings.EnableCompression = false + settings.ReadBufferSize = 0 + settings.WriteBufferSize = 0 + }) + if err != nil { fmt.Println(err) return } - for _, r := range result { - fmt.Println(r.GetString()) - } -} + + defer driverRemoteConnection.Close() + g := gremlingo.Traversal_().WithRemote(driverRemoteConnection) + + g.AddV().Iterate() + count, _ := g.V().Count().Next() + fmt.Println("Vertex count:", *count) +} \ No newline at end of file diff --git a/gremlin-go/example/go.mod b/gremlin-go/examples/go.mod similarity index 81% rename from gremlin-go/example/go.mod rename to gremlin-go/examples/go.mod index 75d6f1c487e..acfd53ab41d 100644 --- a/gremlin-go/example/go.mod +++ b/gremlin-go/examples/go.mod @@ -19,11 +19,11 @@ module example go 1.20 -require github.com/apache/tinkerpop/gremlin-go/v3 v3.6.1-rc2 +require github.com/apache/tinkerpop/gremlin-go/v3 v3.7.0 require ( github.com/google/uuid v1.3.0 // indirect - github.com/gorilla/websocket v1.4.2 // indirect - github.com/nicksnyder/go-i18n/v2 v2.1.2 // indirect - golang.org/x/text v0.3.7 // indirect + github.com/gorilla/websocket v1.5.0 // indirect + github.com/nicksnyder/go-i18n/v2 v2.2.1 // indirect + golang.org/x/text v0.11.0 // indirect ) diff --git a/gremlin-go/examples/go.sum b/gremlin-go/examples/go.sum new file mode 100644 index 00000000000..5aa72a5d11c --- /dev/null +++ b/gremlin-go/examples/go.sum @@ -0,0 +1,44 @@ +github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU= +github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/apache/tinkerpop/gremlin-go/v3 v3.7.0 h1:WSHdJ/UKSSYZj8E2QzEdUsaV54rWAoNlQSPm4x/o/sY= +github.com/apache/tinkerpop/gremlin-go/v3 v3.7.0/go.mod h1:3cydTAyTJzOEI4RWqbNHtsbtnUuYmBR8ZeAxNs+yRcw= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/nicksnyder/go-i18n/v2 v2.2.1 h1:aOzRCdwsJuoExfZhoiXHy4bjruwCMdt5otbYojM/PaA= +github.com/nicksnyder/go-i18n/v2 v2.2.1/go.mod h1:fF2++lPHlo+/kPaj3nB0uxtPwzlPm+BlgwGX7MkeGj0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/gremlin-go/examples/modern_traversals.go b/gremlin-go/examples/modern_traversals.go new file mode 100644 index 00000000000..a1c9ad83203 --- /dev/null +++ b/gremlin-go/examples/modern_traversals.go @@ -0,0 +1,77 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +package main + +import ( + "fmt" + + "github.com/apache/tinkerpop/gremlin-go/v3/driver" +) + +var __ = gremlingo.T__ +var T = gremlingo.T +var P = gremlingo.P + +func main() { + driverRemoteConnection, err := gremlingo.NewDriverRemoteConnection("ws://localhost:8182/gremlin") + if err != nil { + fmt.Println(err) + return + } + defer driverRemoteConnection.Close() + g := gremlingo.Traversal_().WithRemote(driverRemoteConnection) + + /* + This example requires the Modern toy graph to be preloaded upon launching the Gremlin server. + For details, see https://tinkerpop.apache.org/docs/current/reference/#gremlin-server-docker-image and use + conf/gremlin-server-modern.yaml. + */ + e1, err := g.V(1).BothE().ToList() // (1) + e2, err := g.V().BothE().Where(__.OtherV().HasId(2)).ToList() // (2) + v1, err := g.V(1).Next() + v2, err := g.V(2).Next() + v1Vertex, err := v1.GetVertex() + v2Vertex, err := v2.GetVertex() + e3, err := g.V(v1Vertex).BothE().Where(__.OtherV().Is(v2Vertex)).ToList() // (3) + e4, err := g.V(v1Vertex).OutE().Where(__.InV().Is(v2Vertex)).ToList() // (4) + e5, err := g.V(1).OutE().Where(__.InV().Has(T.Id, P.Within(2, 3))).ToList() // (5) + e6, err := g.V(1).Out().Where(__.In().HasId(6)).ToList() // (6) + + fmt.Println(e1) + fmt.Println(e2) + fmt.Println(e3) + fmt.Println(e4) + fmt.Println(e5) + fmt.Println(e6) + + /* + 1. There are three edges from the vertex with the identifier of "1". + 2. Filter those three edges using the Where()-step using the identifier of the vertex returned by OtherV() to + ensure it matches on the vertex of concern, which is the one with an identifier of "2". + 3. Note that the same traversal will work if there are actual Vertex instances rather than just vertex + identifiers. + 4. The vertex with identifier "1" has all outgoing edges, so it would also be acceptable to use the directional + steps of OutE() and InV() since the schema allows it. + 5. There is also no problem with filtering the terminating side of the traversal on multiple vertices, in this + case, vertices with identifiers "2" and "3". + 6. There’s no reason why the same pattern of exclusion used for edges with Where() can’t work for a vertex + between two vertices. + */ +} diff --git a/gremlin-javascript/examples/.gitignore b/gremlin-javascript/examples/.gitignore new file mode 100644 index 00000000000..2ccbe4656c6 --- /dev/null +++ b/gremlin-javascript/examples/.gitignore @@ -0,0 +1 @@ +/node_modules/ diff --git a/gremlin-javascript/examples/basic-gremlin.js b/gremlin-javascript/examples/basic-gremlin.js new file mode 100644 index 00000000000..77e7f3b7d9f --- /dev/null +++ b/gremlin-javascript/examples/basic-gremlin.js @@ -0,0 +1,51 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +const gremlin = require('gremlin'); +const traversal = gremlin.process.AnonymousTraversalSource.traversal; +const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection; + +async function main() { + const dc = new DriverRemoteConnection('ws://localhost:8182/gremlin'); + const g = traversal().withRemote(dc); + + // Basic Gremlin: adding and retrieving data + const v1 = await g.addV('person').property('name','marko').next(); + const v2 = await g.addV('person').property('name','stephen').next(); + const v3 = await g.addV('person').property('name','vadas').next(); + + // Be sure to use a terminating step like next() or iterate() so that the traversal "executes" + // Iterate() does not return any data and is used to just generate side-effects (i.e. write data to the database) + await g.V(v1.value).addE('knows').to(v2.value).property('weight',0.75).iterate(); + await g.V(v1.value).addE('knows').to(v3.value).property('weight',0.75).iterate(); + + // Retrieve the data from the "marko" vertex + const marko = await g.V().has('person','name','marko').values('name').toList(); + console.log("name: " + marko[0]); + + // Find the "marko" vertex and then traverse to the people he "knows" and return their data + const peopleMarkoKnows = await g.V().has('person','name','marko').out('knows').values('name').toList(); + peopleMarkoKnows.forEach((person) => { + console.log("marko knows " + person); + }); + + await dc.close(); +} + +main(); \ No newline at end of file diff --git a/gremlin-javascript/examples/connections.js b/gremlin-javascript/examples/connections.js new file mode 100644 index 00000000000..183f6404f6e --- /dev/null +++ b/gremlin-javascript/examples/connections.js @@ -0,0 +1,65 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +const gremlin = require('gremlin'); +const traversal = gremlin.process.AnonymousTraversalSource.traversal; +const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection; +const serializer = gremlin.structure.io.graphserializer; + +async function main() { + await withRemote(); + await withConfigs(); +} + +async function withRemote() { + // Connecting to the server + const dc = new DriverRemoteConnection('ws://localhost:8182/gremlin'); + const g = traversal().withRemote(dc); + + // Drop existing vertices + await g.V().drop().iterate(); + + // Simple query to verify connection + const v = await g.addV().iterate(); + const count = await g.V().count().next(); + console.log("Vertex count: " + count.value); + + // Cleanup + await dc.close(); +} + +async function withConfigs() { + // Connecting and customizing configurations + const dc = new DriverRemoteConnection('ws://localhost:8182/gremlin', { + mimeType: 'application/vnd.gremlin-v3.0+json', + reader: serializer, + writer: serializer, + rejectUnauthorized: false, + traversalSource: 'g', + }); + const g = traversal().withRemote(dc); + + const v = await g.addV().iterate(); + const count = await g.V().count().next(); + console.log("Vertex count: " + count.value); + + await dc.close(); +} + +main(); \ No newline at end of file diff --git a/gremlin-javascript/examples/modern-traversals.js b/gremlin-javascript/examples/modern-traversals.js new file mode 100644 index 00000000000..66b039fca38 --- /dev/null +++ b/gremlin-javascript/examples/modern-traversals.js @@ -0,0 +1,69 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +const gremlin = require('gremlin'); +const traversal = gremlin.process.AnonymousTraversalSource.traversal; +const __ = gremlin.process.statics; +const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection; +const p = gremlin.process.P; +const t = gremlin.process.t; + +async function main() { + /* + This example requires the Modern toy graph to be preloaded upon launching the Gremlin server. + For details, see https://tinkerpop.apache.org/docs/current/reference/#gremlin-server-docker-image and use + conf/gremlin-server-modern.yaml. + */ + const dc = new DriverRemoteConnection('ws://localhost:8182/gremlin'); + const g = traversal().withRemote(dc); + + const e1 = await g.V(1).bothE().toList(); // (1) + const e2 = await g.V(1).bothE().where(__.otherV().hasId(2)).toList(); // (2) + const v1 = await g.V(1).next(); + const v2 = await g.V(2).next(); + const e3 = await g.V(v1.value).bothE().where(__.otherV().is(v2.value)).toList(); // (3) + const e4 = await g.V(v1.value).outE().where(__.inV().is(v2.value)).toList(); // (4) + const e5 = await g.V(1).outE().where(__.inV().has(t.id, p.within(2,3))).toList(); // (5) + const e6 = await g.V(1).out().where(__.in_().hasId(6)).toList(); // (6) + + console.log("1: " + e1.toString()); + console.log("2: " + e2.toString()); + console.log("3: " + e3.toString()); + console.log("4: " + e4.toString()); + console.log("5: " + e5.toString()); + console.log("6: " + e6.toString()); + + /* + 1. There are three edges from the vertex with the identifier of "1". + 2. Filter those three edges using the where()-step using the identifier of the vertex returned by otherV() to + ensure it matches on the vertex of concern, which is the one with an identifier of "2". + 3. Note that the same traversal will work if there are actual Vertex instances rather than just vertex + identifiers. + 4. The vertex with identifier "1" has all outgoing edges, so it would also be acceptable to use the directional + steps of outE() and inV() since the schema allows it. + 5. There is also no problem with filtering the terminating side of the traversal on multiple vertices, in this + case, vertices with identifiers "2" and "3". + 6. There’s no reason why the same pattern of exclusion used for edges with where() can’t work for a vertex + between two vertices. + */ + + await dc.close(); +} + +main(); \ No newline at end of file diff --git a/gremlin-javascript/examples/package-lock.json b/gremlin-javascript/examples/package-lock.json new file mode 100644 index 00000000000..4898ff144d0 --- /dev/null +++ b/gremlin-javascript/examples/package-lock.json @@ -0,0 +1,47 @@ +{ + "name": "example", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "example", + "version": "1.0.0", + "license": "Apache-2.0", + "dependencies": { + "gremlin": "^3.7.0" + } + }, + "node_modules/gremlin": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/gremlin/-/gremlin-3.7.0.tgz", + "integrity": "sha512-LEjUtDEJB3ddij3VSb769b2TkLu29h30G+zrz/T9hyrnSouiOCzvgTHoMZq3wUig2O+oYLCgcPRw0iquBUoqnw==", + "dependencies": { + "ws": "^8.11.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/ws": { + "version": "8.14.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.1.tgz", + "integrity": "sha512-4OOseMUq8AzRBI/7SLMUwO+FEDnguetSk7KMb1sHwvF2w2Wv5Hoj0nlifx8vtGsftE/jWHojPy8sMMzYLJ2G/A==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } +} diff --git a/gremlin-javascript/examples/package.json b/gremlin-javascript/examples/package.json new file mode 100644 index 00000000000..05e0bebf832 --- /dev/null +++ b/gremlin-javascript/examples/package.json @@ -0,0 +1,14 @@ +{ + "name": "example", + "version": "1.0.0", + "description": "GLV example for JavaScript with Node", + "main": "example.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Ryan Tan", + "license": "Apache-2.0", + "dependencies": { + "gremlin": "^3.7.0" + } +} diff --git a/gremlin-python/src/main/python/example.py b/gremlin-python/src/main/python/example.py deleted file mode 100644 index 64e0c0bfee1..00000000000 --- a/gremlin-python/src/main/python/example.py +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from gremlin_python.process.anonymous_traversal import traversal -from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection -import json - - -to_string = json.dumps - - -def main(): - - # connect to a remote server that is compatible with the Gremlin Server protocol. for those who - # downloaded and are using Gremlin Server directly be sure that it is running locally with: - # - # bin/gremlin-server.sh console - # - # which starts it in "console" mode with an empty in-memory TinkerGraph ready to go bound to a - # variable named "g" as referenced in the following line. - g = traversal().with_remote(DriverRemoteConnection('ws://localhost:8182/gremlin', 'g')) - - # add some data - be sure to use a terminating step like iterate() so that the traversal - # "executes". iterate() does not return any data and is used to just generate side-effects - # (i.e. write data to the database) - g.add_v('person').property('name', 'marko').as_('m'). \ - add_v('person').property('name', 'vadas').as_('v'). \ - add_e('knows').from_('m').to('v').iterate() - - # retrieve the data from the "marko" vertex - print("marko: " + to_string(g.V().has('person', 'name', 'marko').value_map().next())) - - # find the "marko" vertex and then traverse to the people he "knows" and return their data - print("who marko knows: " + to_string(g.V().has('person', 'name', 'marko').out('knows').value_map().next())) - - -if __name__ == "__main__": - main() diff --git a/gremlin-python/src/main/python/examples/basic_gremlin.py b/gremlin-python/src/main/python/examples/basic_gremlin.py new file mode 100644 index 00000000000..256ed984416 --- /dev/null +++ b/gremlin-python/src/main/python/examples/basic_gremlin.py @@ -0,0 +1,54 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import sys + +sys.path.append("..") + +from gremlin_python.process.anonymous_traversal import traversal +from gremlin_python.process.strategies import * +from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection + + +def main(): + rc = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g') + g = traversal().with_remote(rc) + + # basic Gremlin: adding and retrieving data + v1 = g.add_v('person').property('name', 'marko').next() + v2 = g.add_v('person').property('name', 'stephen').next() + v3 = g.add_v('person').property('name', 'vadas').next() + + # be sure to use a terminating step like next() or iterate() so that the traversal "executes" + # iterate() does not return any data and is used to just generate side-effects (i.e. write data to the database) + g.V(v1).add_e('knows').to(v2).property('weight', 0.75).iterate() + g.V(v1).add_e('knows').to(v3).property('weight', 0.75).iterate() + + # retrieve the data from the "marko" vertex + marko = g.V().has('person', 'name', 'marko').values('name').next() + print("name: " + marko) + + # find the "marko" vertex and then traverse to the people he "knows" and return their data + people_marko_knows = g.V().has('person', 'name', 'marko').out('knows').values('name').to_list() + for person in people_marko_knows: + print("marko knows " + person) + + rc.close() + + +if __name__ == "__main__": + main() diff --git a/gremlin-python/src/main/python/examples/connections.py b/gremlin-python/src/main/python/examples/connections.py new file mode 100644 index 00000000000..f268e6c27d5 --- /dev/null +++ b/gremlin-python/src/main/python/examples/connections.py @@ -0,0 +1,101 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import sys + +sys.path.append("..") + +from gremlin_python.process.anonymous_traversal import traversal +from gremlin_python.process.strategies import * +from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection +from gremlin_python.driver.serializer import GraphBinarySerializersV1 + + +def main(): + with_remote() + with_auth() + with_kerberos() + with_configs() + + +def with_remote(): + # connect to a remote server that is compatible with the Gremlin Server protocol. for those who + # downloaded and are using Gremlin Server directly be sure that it is running locally with: + # + # bin/gremlin-server.sh console + # + # which starts it in "console" mode with an empty in-memory TinkerGraph ready to go bound to a + # variable named "g" as referenced in the following line. + rc = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g') + g = traversal().with_remote(rc) + + # drop existing vertices + g.V().drop().iterate() + + # simple query to verify connection + v = g.add_v().iterate() + count = g.V().count().next() + print("Vertex count: " + str(count)) + + # cleanup + rc.close() + + +# connecting with plain text authentication +def with_auth(): + rc = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g', username='stephen', password='password') + g = traversal().with_remote(rc) + + v = g.add_v().iterate() + count = g.V().count().next() + print("Vertex count: " + str(count)) + + rc.close() + + +# connecting with Kerberos SASL authentication +def with_kerberos(): + rc = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g', kerberized_service='gremlin@hostname.your.org') + g = traversal().with_remote(rc) + + v = g.add_v().iterate() + count = g.V().count().next() + print("Vertex count: " + str(count)) + + rc.close() + + +# connecting with customized configurations +def with_configs(): + rc = DriverRemoteConnection( + 'ws://localhost:8182/gremlin', 'g', + username="", password="", kerberized_service='', + message_serializer=GraphBinarySerializersV1(), graphson_reader=None, + graphson_writer=None, headers=None, session=None, + enable_user_agent_on_connect=True + ) + g = traversal().with_remote(rc) + + v = g.add_v().iterate() + count = g.V().count().next() + print("Vertex count: " + str(count)) + + rc.close() + + +if __name__ == "__main__": + main() diff --git a/gremlin-python/src/main/python/examples/modern_traversals.py b/gremlin-python/src/main/python/examples/modern_traversals.py new file mode 100644 index 00000000000..ae757b10b4f --- /dev/null +++ b/gremlin-python/src/main/python/examples/modern_traversals.py @@ -0,0 +1,69 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import sys + +sys.path.append("..") + +from gremlin_python.process.anonymous_traversal import traversal +from gremlin_python.process.graph_traversal import __ +from gremlin_python.process.strategies import * +from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection +from gremlin_python.process.traversal import T +from gremlin_python.process.traversal import P + + +def main(): + # This example requires the Modern toy graph to be preloaded upon launching the Gremlin server. + # For details, see https://tinkerpop.apache.org/docs/current/reference/#gremlin-server-docker-image and use + # conf/gremlin-server-modern.yaml. + rc = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g') + g = traversal().with_remote(rc) + + e1 = g.V(1).both_e().to_list() # (1) + e2 = g.V(1).both_e().where(__.other_v().has_id(2)).to_list() # (2) + v1 = g.V(1).next() + v2 = g.V(2).next() + e3 = g.V(v1).both_e().where(__.other_v().is_(v2)).to_list() # (3) + e4 = g.V(v1).out_e().where(__.in_v().is_(v2)).to_list() # (4) + e5 = g.V(1).out_e().where(__.in_v().has(T.id, P.within(2, 3))).to_list() # (5) + e6 = g.V(1).out().where(__.in_().has_id(6)).to_list() # (6) + + print("1: " + str(e1)) + print("2: " + str(e2)) + print("3: " + str(e3)) + print("4: " + str(e4)) + print("5: " + str(e5)) + print("6: " + str(e6)) + + # 1. There are three edges from the vertex with the identifier of "1". + # 2. Filter those three edges using the where()-step using the identifier of the vertex returned by other_v() to + # ensure it matches on the vertex of concern, which is the one with an identifier of "2". + # 3. Note that the same traversal will work if there are actual Vertex instances rather than just vertex + # identifiers. + # 4. The vertex with identifier "1" has all outgoing edges, so it would also be acceptable to use the directional + # steps of out_e() and in_v() since the schema allows it. + # 5. There is also no problem with filtering the terminating side of the traversal on multiple vertices, in this + # case, vertices with identifiers "2" and "3". + # 6. There’s no reason why the same pattern of exclusion used for edges with where() can’t work for a vertex + # between two vertices. + + rc.close() + + +if __name__ == "__main__": + main() diff --git a/gremlin-python/src/main/python/examples/requirements.txt b/gremlin-python/src/main/python/examples/requirements.txt new file mode 100644 index 00000000000..64f860071bd --- /dev/null +++ b/gremlin-python/src/main/python/examples/requirements.txt @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +aenum==3.1.15 +aiohttp==3.8.0 +aiosignal==1.3.1 +async-timeout==4.0.3 +attrs==23.1.0 +charset-normalizer==2.1.1 +frozenlist==1.4.0 +idna==3.4 +isodate==0.6.1 +multidict==4.7.6 +six==1.15.0 +yarl==1.9.2 \ No newline at end of file