package
3.7.3
Repository: https://github.com/apache/tinkerpop.git
Documentation: pkg.go.dev

# README

Getting Started

Prerequisites

  • gremlin-go requires Golang 1.22 or later, please see Go Download for more details on installing Golang.
  • A basic understanding of Go Modules
  • A project set up which uses Go Modules

Installing the Gremlin-Go as a dependency

To install the Gremlin-Go as a dependency for your project, run the following in the root directory of your project that contains your go.mod file:

go get github.com/apache/tinkerpop/gremlin-go/v3[optionally append @<version>, such as @v3.5.3 - note this requires GO111MODULE=on]

Available versions can be found at pkg.go.dev.

After running the go get command, your go.mod file should contain something similar to the following:

module gremlin-go-example

go 1.22

require github.com/apache/tinkerpop/gremlin-go/v3 v<version>

If it does, then this means Gremlin-Go was successfully installed as a dependency of your project.

You will need to run go mod tidy to import the remaining dependencies of the gremlin-go driver (if your IDE does not do so automatically), after which you should see an updated go.mod file:

module gremlin-go-example

go 1.22

require github.com/apache/tinkerpop/gremlin-go v0.0.0-20220131225152-54920637bf94

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
)

As well as a populated go.sum file.

if there are no usages for gremlingo found, it will remove the require from go.mod and not import dependencies.

Simple usage

For instructions on simple usage, including connecting, connection settings, aliases and more, check out the Gremlin-Go section in the Tinkerpop Documentation.

Troubleshooting

Can't establish connection and get any result

  • Verify you are using valid server protocol and path. Note that for secure connection wss should be used.
  • Verify firewall settings.

Local server doesn't have valid certificate

  • Set connection option &tls.Config{InsecureSkipVerify: true}

Client hangs on requests with large amount of data

  • Increase read buffer size by settings connection option readBufferSize.

Gremlin-Go Development

Design Architecture

See Gremlin-Go Design Overview

Building Directly

To build the driver you must install go. The following command can be used to build the driver: go build <path to source code>

Code Styling and Linting

Before generating a pull request, you should manually run the following to ensure correct code styling and fix any issues indicated by the linters.

Formatting files with Gofmt

To ensure clean and readable code Gofmt is used.

Navigate to file path in a terminal window and run:

go fmt

Gofmt will recursively check for and format .go files.

Note: If your IDE of choice is GoLand, code can be automatically formatted with Gofmt on file save. Instructions on how to enable this feature can be found here.

Using the Linter and staticcheck

Run go vet and staticcheck and correct any errors.

go vet is installed when you install go, and can be run with:

go vet <path to source code>

Please review the staticcheck documentation for more details on installing staticcheck. It can be run with:

staticcheck <path to source code>

Testing with Docker

Docker allows you to test the driver without installing any dependencies. Gremlin Go uses Docker for all of its testing. Please make sure Docker is installed and running on your system. You will need to install both Docker Engine and Docker Compose, which are included in Docker Desktop.

The docker compose environment variable GREMLIN_SERVER specifies the Gremlin server docker image to use, i.e. an image with the tag tinkerpop/gremlin-server:$GREMLIN_SERVER, and is a required environment variable. This also requires the specified docker image to exist, either locally or in Docker Hub.

Running mvn clean install -pl gremlin-server -DskipTests -DskipIntegrationTests=true -Dci -am in the main tinkerpop directory will automatically build a local SNAPSHOT Gremlin server image. If your OS Platform cannot build a local SNAPSHOT Gremlin server through maven, it is recommended to use the latest released server version from Docker Hub (do not use GREMLIN_SERVER=latest, use actual version number, e.g. GREMLIN_SERVER=3.5.x or GREMLIN_SERVER=3.6.x).

The docker compose environment variable HOME specifies the user home directory for mounting volumes during test image set up. This variable is set by default in Unix/Linux, but will need to be set for Windows, for example, run $env:HOME=$env:USERPROFILE in PowerShell.

There are different ways to launch the test suite and set the GREMLIN_SERVER environment variable depending on your Platform:

  • Run Maven commands, e.g. mvn clean install inside of tinkerpop/gremlin-go, or mvn clean install -pl gremlin-go inside of tinkerpop (platform-agnostic - recommended)
  • Run the run.sh script, which sets GREMLIN_SERVER by default. Run ./run.sh -h for usage information (Unix/Linux - recommended).
  • Add GREMLIN_SERVER=<server-image-version> and HOME=<user-home-directory> to an .env file inside gremlin-go and run docker compose up --exit-code-from gremlin-go-integration-tests (Platform-agnostic).
  • Run GREMLIN_SERVER=<server-image-version> docker compose up --exit-code-from gremlin-go-integration-tests in Unix/Linux.
  • Run $env:GREMLIN_SERVER="<server-image-version>";$env:HOME=$env:USERPROFILE;docker compose up --exit-code-from gremlin-go-integration-tests in Windows PowerShell.

You should see exit code 0 upon successful completion of the test suites. Run docker compose down to remove the service containers (not needed if you executed Maven commands or run.sh), or docker compose down --rmi all to remove the service containers while deleting all used images.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

AdjacentToIncidentStrategy looks for Vertex- and value-emitting steps followed by a CountGlobalStep and replaces the pattern with an Edge- or Property-emitting step followed by a CountGlobalStep.
BasicAuthInfo provides a way to generate AuthInfo.
ByModulatorOptimizationStrategy looks for standard traversals in By-modulators and replaces them with more optimized traversals (e.g.
ConnectiveStrategy rewrites the binary conjunction form of a.And().b into a AndStep of And(a,b) (likewise for OrStep).
CountStrategy optimizes any occurrence of CountGlobalStep followed by an IsStep The idea is to limit the number of incoming elements in a way that it's enough for the IsStep to decide whether it evaluates true or false.
EarlyLimitStrategy looks for RangeGlobalSteps that can be moved further left in the traversal and thus be applied earlier.
EdgeLabelVerificationStrategy does not allow Edge traversal steps to have no label specified.
ElementIdStrategy provides a degree of control over element identifier assignment as some Graphs don't provide that feature.
FilterRankingStrategy reorders filter- and order-steps according to their rank.
No description provided by the author
HeaderAuthInfo provides a way to generate AuthInfo with only Header information.
IdentityRemovalStrategy looks for IdentityStep instances and removes them.
IncidentToAdjacentStrategy looks for .OutE().InV(), .InE().OutV() and .BothE().OtherV() and replaces these step sequences with .Out(), .In() or .Both() respectively.
InlineFilterStrategy analyzes filter-steps with child traversals that themselves are pure filters.
LambdaRestrictionStrategy does not allow lambdas to be used in a Traversal.
LazyBarrierStrategy is an OLTP-only strategy that automatically inserts a NoOpBarrierStep after every FlatMapStep if neither Path-tracking nor partial Path-tracking is required, and the next step is not the traversal's last step or a barrier.
No description provided by the author
MatchPredicateStrategy will fold any post-Where() step that maintains a traversal constraint into Match().
NewBytecode creates a new Bytecode to be used in traversals.
NewClient creates a Client and configures it with the given parameters.
NewDefaultGraphTraversalSource creates a new graph GraphTraversalSource without a graph, strategy, or existing traversal.
NewDriverRemoteConnection creates a new DriverRemoteConnection.
NewDynamicAuth provides a way to generate dynamic credentials with the specified generator function.
NewGraphTraversal make a new GraphTraversal.
NewGraphTraversalSource creates a new GraphTraversalSource from a Graph, DriverRemoteConnection, and any TraversalStrategy.
NewSimpleSet creates a new SimpleSet containing all passed in args with duplicates excluded according to Golang equality operator rules.
No description provided by the author
OptionsStrategy will not alter the Traversal.
OrderLimitStrategy is an OLAP strategy that folds a RangeGlobalStep into a preceding OrderGlobalStep.
PartitionStrategy partitions the Vertices, Edges and Vertex properties of a Graph into String named partitions (i.e.
PathProcessorStrategy is an OLAP strategy that does its best to turn non-local children in Where() and Select() into local children by inlining components of the non-local child.
PathRetractionStrategy will remove Paths from the Traversers and increase the likelihood of bulking as Path data is not required after Select('b').
ProductiveByStrategy takes an argument of By() and wraps it CoalesceStep so that the result is either the initial Traversal argument or null.
ReadOnlyStrategy detects steps marked with Mutating and returns an error if one is found.
RegisterCustomTypeReader register a reader (deserializer) for a custom type.
RemoteStrategy reconstructs a Traversal by appending a RemoteStep to its end.
RepeatUnrollStrategy is an OLTP-only strategy that unrolls any RepeatStep if it uses a constant number of loops (Times(x)) and doesn't emit intermittent elements.
ReservedKeysVerificationStrategy detects property keys that should not be used by the traversal.
SeedStrategy resets the specified Seed value for Seedable steps, which in turn will produce deterministic results from those steps.
SubgraphStrategy provides a way to limit the view of a Traversal.
Traversal_ gets an AnonymousTraversalSource.
UnregisterCustomTypeReader unregister a reader (deserializer) for a custom type.
No description provided by the author

# Constants

Debug verbosity will log everything, including fine details.
Error verbosity level log only error messages.
Gorilla transport layer: github.com/gorilla/websocket.
Info verbosity will log messages up to standard procedure flow.
Off verbosity level disables logging.
Warning verbosity will log messages up to warnings.

# Variables

Barrier is any step that requires all left traversers to be processed prior to emitting result traversers to the right.
Cardinality of Vertex Properties.
No description provided by the author
Column references a particular type of column in a complex data structure.
Direction is used to denote the direction of an Edge or location of a Vertex on an Edge.
Merge is a set of operations for Vertex and Edge merging.
MaterializeProperties is string symbols.
Merge is a set of operations for Vertex and Edge merging.
NoopAuthInfo is a no-op AuthInfoProvider that can be used to disable authentication.
Operator is a set of operations for traversal steps.
Order provides comparator instances for ordering traversers.
No description provided by the author
No description provided by the author
Pop is used to determine whether the first value, last value, or all values are gathered.
Scope is used in many Step instance can have a variable scope which alter the manner in which the step will behave in relation to how the traversers are processed.
T is string symbols.
No description provided by the author
No description provided by the author
WithOptions holds configuration options to be passed to the GraphTraversal.

# Structs

AuthInfo is an option struct that allows authentication information to be specified statically.
BigDecimal represents an arbitrary-precision signed decimal number, consisting of an arbitrary precision integer unscaled value and a 32-bit integer scale.
Binding associates a string variable with a value.
Bindings are used to associate a variable with a value.
ByteBuffer represents the GraphBinary type ByteBuffer which can be used to serialize a binary data.
Bytecode a list of ordered instructions for traversal that can be serialized between environments and machines.
Client is used to connect and interact with a Gremlin-supported server.
ClientSettings is used to modify a Client's settings on initialization.
DriverRemoteConnection is a remote connection.
DriverRemoteConnectionSettings are used to configure the DriverRemoteConnection.
DynamicAuth is an AuthInfoProvider that allows dynamic credential generation.
Edge links two Vertex structs along with its Property Objects.
EdgeLabelVerificationStrategyConfig provides configuration options for EdgeLabelVerificationStrategy.
Element is the base structure for both Vertex and Edge.
Graph is used to store the graph.
GraphTraversal stores a Traversal.
GraphTraversalSource can be used to start GraphTraversal.
GremlinType represents the GraphBinary type Class which can be used to serialize a class.
HaltedTraverserStrategyConfig provides configuration options for HaltedTraverserStrategy.
No description provided by the author
MatchAlgorithmStrategyConfig provides configuration options for MatchAlgorithmStrategy.
Metrics holds metrics data; typically for .profile()-step analysis.
PartitionStrategyConfig provides configuration options for PartitionStrategy.
Path denotes a particular walk through a Graph as defined by a traversal.
ProductiveByStrategyConfig provides configuration options for ProductiveByStrategy.
Property denotes a Key/Value pair associated with an Edge.
No description provided by the author
No description provided by the author
ReservedKeysVerificationStrategyConfig provides configuration options for ReservedKeysVerificationStrategy.
Result Struct to abstract the Result and provide functions to use it.
SeedStrategyConfig provides configuration options for SeedStrategy.
SimpleSet is a basic implementation of a Set for use with Gremlin-Go.
SubgraphStrategyConfig provides configuration options for SubgraphStrategy.
No description provided by the author
Traversal is the primary way in which graphs are processed.
TraversalMetrics contains the Metrics gathered for a Traversal as the result of the .profile()-step.
Traverser is the objects propagating through the traversal.
Vertex contains a single Vertex which has a Label and an Id.
VertexProgramStrategyConfig provides configuration options for VertexProgramStrategy.
VertexProperty is similar to property in that it denotes a key/value pair associated with a Vertex, but is different in that it also represents an entity that is an Element and can have properties of its own.

# Interfaces

AnonymousTraversal interface for anonymous traversals.
AnonymousTraversalSource interface for generating anonymous traversals.
AuthInfoProvider is an interface that allows authentication information to be specified.
No description provided by the author
Logger is the interface required to be implemented for use with gremlingo.
Predicate interface.
ResultSet interface to define the functions of a ResultSet.
Set describes the necessary methods that need to be implemented for Gremlin-Go to recognize for use as a Gremlin Set.
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

CustomTypeReader user provided function to deserialize custom types.
LogVerbosity is an alias for valid logging verbosity levels.
TransporterType is an alias for valid transport protocols.