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 Map
- type Options
- type Path
- type Pred
- type Prop
- type Property
- type Server
- type Set
- type Step
- type Stmt
- type Token
- type Traversal
- 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.
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.
func NewEngine ¶
func NewEngine() *Engine
NewEngine returns an engine with every supported step registered.
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 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
}
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 Traversal ¶
type Traversal struct {
Steps []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.