Documentation
¶
Overview ¶
Package gremlin is an in-process Apache TinkerPop Gremlin server over the shared openCypher property graph.
It speaks the Gremlin Server WebSocket protocol (GraphSON v2/v3 and GraphBinary v1) and the HTTP endpoint, and runs Gremlin scripts and bytecode against the same nodes and relationships as openCypher and Bolt.
Index ¶
- Constants
- func DeniedError(detail string) error
- func DeniedFrame(req FrameRequest, err error) (int, []byte)
- type Access
- type Edge
- type Engine
- type Error
- type FrameRequest
- type GraphEdge
- type GraphProp
- type GraphVertex
- type Map
- type Option
- type Options
- type Path
- type Pred
- type Prop
- type Property
- type Server
- type Set
- type Step
- type Stmt
- type SubGraph
- type Token
- type Traversal
- type Tree
- type UUID
- type Vertex
- type VertexRef
Constants ¶
const ( CodeMalformedQuery = "MalformedQueryException" CodeInvalidParameter = "InvalidParameterException" CodeConstraintViolation = "ConstraintViolationException" CodeUnsupported = "UnsupportedOperationException" CodeTimeLimit = "TimeLimitExceededException" CodeCancelled = "CancelledByUserException" CodeInternal = "InternalFailureException" )
Neptune error codes returned by the HTTP endpoint; WebSocket clients get the Gremlin Server status instead.
const ( StatusSuccess = 200 StatusNoContent = 204 StatusPartial = 206 StatusForbidden = 403 StatusInvalidRequest = 499 StatusServerError = 500 StatusScriptEvalError = 597 StatusServerTimeout = 598 StatusSerializationErr = 599 )
Gremlin Server response status codes.
const DefaultSessionLifetime = 10 * time.Minute
DefaultSessionLifetime is the longest a session may stay open before it is rolled back.
Variables ¶
This section is empty.
Functions ¶
func DeniedError ¶
DeniedError is the AccessDeniedException a client receives when detail explains the refusal.
func DeniedFrame ¶
func DeniedFrame(req FrameRequest, err error) (int, []byte)
DeniedFrame builds the response frame refusing req with err, in the codec the client used.
Types ¶
type Access ¶
Access is the extra permission a query needs beyond read; every query reads.
func ScriptAccess ¶
ScriptAccess scans a script for steps that can write or delete; it over-approximates, never under.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine runs Gremlin against an openCypher graph.
type Error ¶
Error is a query failure carrying the Gremlin Server status and the Neptune error code.
type FrameRequest ¶
FrameRequest is a client request frame inspected without being executed.
func ClassifyFrame ¶
func ClassifyFrame(messageType int, data []byte) (FrameRequest, error)
ClassifyFrame parses a client request frame (GraphSON text or mime-prefixed binary) and reports the access its script or bytecode needs. Frames that cannot be understood, or ops other than eval, bytecode, close and authentication, yield an error and a FrameRequest carrying whatever correlation could be recovered.
type GraphProp ¶
GraphProp is one property of a SubGraph element; vertices may carry several values per key.
type GraphVertex ¶
GraphVertex is a vertex of a SubGraph with its properties.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map is an insertion-ordered map whose keys may be any value.
type Options ¶
type Options struct {
// Track registers a running query and returns its cancellable context and a finish callback.
Track func(parent context.Context, query string) (context.Context, func())
// Authorize, when set, vets each query before it runs; ctx is the request (or WebSocket handshake) context.
Authorize func(ctx context.Context, write, del bool) error
Timeout time.Duration
// SessionLifetime caps how long a session may stay open (default DefaultSessionLifetime).
SessionLifetime time.Duration
}
Options configures a Server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server serves Gremlin over WebSocket and HTTP against one graph.
type Step ¶
type Step struct {
Name string
Args []any
Mods []Step
// Pre marks a modulator written before its step (until/emit before repeat).
Pre bool
}
Step is one step with its arguments and the modulators ("by", "from", modTimes, ...) that follow it.
type SubGraph ¶
type SubGraph struct {
Vertices []*GraphVertex
Edges []*GraphEdge
}
SubGraph is the TinkerGraph-like result of cap() over subgraph(key).
type Traversal ¶
type Traversal struct {
Steps []Step
// Sources are the bytecode source instructions (withSideEffect, tx, ...).
Sources []Step
}
Traversal is a parsed Gremlin traversal: the steps after g (or inside an anonymous __).
func (*Traversal) Access ¶
Access reports what the traversal's steps, modulators and nested traversals can do to the graph.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree is a Gremlin Tree: an insertion-ordered map from a path element to the subtree below it.
type UUID ¶
type UUID string
UUID is a java.util.UUID value; Neptune rejects it as a property value.
Source Files
¶
- access.go
- ast.go
- bulk.go
- by.go
- bytesio.go
- consts.go
- elements.go
- engine.go
- errors.go
- exec.go
- frame.go
- graphbinary.go
- graphson.go
- index.go
- lexer.go
- math.go
- parser.go
- pred.go
- sack.go
- sample.go
- server.go
- session.go
- steps.go
- steps_branch.go
- steps_filter.go
- steps_merge.go
- steps_mutate.go
- steps_nav.go
- steps_project.go
- steps_reduce.go
- steps_source.go
- steps_string.go
- subgraph.go
- tree.go
- uuid.go
- values.go