Documentation ¶
Index ¶
- Constants
- Variables
- func CharSliceToMap(chars []rune) map[rune]bool
- func CoalesceStrings(s ...string) string
- func ContextWithOpName(ctx context.Context, name string) context.Context
- func CreateConnection() (conn net.Conn, server *url.URL, err error)
- func EdgesMatch(edge1, edge2 Edge) bool
- func EmptyTags() []string
- func EscapeGremlin(value string) string
- func GenericValuesMatch(gv1, gv2 GenericValue) bool
- func GraphSONSerializer(req *Request) ([]byte, error)
- func InterfaceToString(i interface{}) string
- func InterfacesMatch(interface1, interface2 interface{}) bool
- func MakeGremlinQuery(gremlinQuery GremlinQuery, argRegexP *regexp.Regexp) (string, error)
- func NewCluster(s ...string) (err error)
- func OpNameFromContext(ctx context.Context) string
- func PrepareArgs(args []interface{}, escapeFn func(string) string) []interface{}
- func SerializeListInterface(rawResponse string) ([]interface{}, error)
- func SplitServers(connString string) (servers []*url.URL, err error)
- func StartSpanFromParent(ctx context.Context, tracer opentracing.Tracer, method string, ...) (opentracing.Span, context.Context)
- func VertexesMatch(vertex1, vertex2 Vertex) bool
- type AuthInfo
- type Bind
- type CleanEdge
- type CleanResponse
- type CleanVertex
- type EdIdType
- type Edge
- type EdgeIdValueType
- type EdgeProperty
- type EdgePropertyValue
- type EdgeV2
- type EdgeValue
- type EdgeValueType
- type EdgeValueV2
- type Edges
- type EdgesV2
- type FormattedReq
- type GenericValue
- type GenericValues
- type GoGremlin
- type GremlinClient
- type GremlinConnection
- func (c *GremlinConnection) Authenticate(requestId string) ([]byte, error)
- func (c *GremlinConnection) Close() error
- func (c *GremlinConnection) Exec(req *Request) ([]byte, error)
- func (c *GremlinConnection) ExecQuery(query string) ([]byte, error)
- func (c *GremlinConnection) MaintainConnection(urlStr string) error
- func (c *GremlinConnection) ReadResponse() (data []byte, err error)
- func (c *GremlinConnection) Reconnect(urlStr string) error
- func (c *GremlinConnection) SetLogVerbosity(verboseLogging bool)
- type GremlinInstr
- type GremlinLogger
- type GremlinQuery
- type GremlinResponse
- type GremlinStackOptions
- type GremlinTracer
- type Gremlin_i
- type IdType
- type IdTypeStruct
- type InstrumentationProvider_i
- type Logger_i
- type OptAuth
- type Request
- type RequestArgs
- type Response
- type ResponseResult
- type ResponseStatus
- type Vertex
- type VertexProperty
- type VertexPropertyValue
- type VertexV2
- type VertexValue
- type VertexValueV2
- type Vertexes
- type VertexesV2
Constants ¶
const ( // Gremlin client does not allow Other characters ARG_REGEX = "\\p{C}+" // Gremlin stack defaults DEFAULT_MAX_CAP = 10 DEFAULT_MAX_GREMLIN_RETRIES = 2 DEFAULT_VERBOSE_LOGGING = false DEFAULT_PING_INTERVAL = 5 )
const ( StatusSuccess = 200 StatusNoContent = 204 StatusPartialContent = 206 StatusAuthenticate = 407 StatusMalformedRequest = 498 StatusInvalidRequestArguments = 499 StatusServerError = 500 StatusScriptEvaluationError = 597 StatusServerTimeout = 598 StatusServerSerializationError = 599 )
Variables ¶
var ESCAPE_CHARS_GREMLIN = CharSliceToMap([]rune{
singleQuote,
backslash,
pctSymbol,
doubleQuote,
})
var ErrClosed = errors.New("pool is closed")
var ErrorMsg = map[int]string{ StatusUnauthorized: "Unauthorized", StatusAuthenticate: "Authenticate", StatusMalformedRequest: "Malformed Request", StatusInvalidRequestArguments: "Invalid Request Arguments", StatusServerError: "Server Error", StatusScriptEvaluationError: "Script Evaluation Error", StatusServerTimeout: "Server Timeout", StatusServerSerializationError: "Server Serialization Error", }
Functions ¶
func CharSliceToMap ¶
func CoalesceStrings ¶
func EdgesMatch ¶
func EscapeGremlin ¶
func GenericValuesMatch ¶
func GenericValuesMatch(gv1, gv2 GenericValue) bool
func GraphSONSerializer ¶
func InterfaceToString ¶
func InterfaceToString(i interface{}) string
func InterfacesMatch ¶
func InterfacesMatch(interface1, interface2 interface{}) bool
func MakeGremlinQuery ¶
func MakeGremlinQuery(gremlinQuery GremlinQuery, argRegexP *regexp.Regexp) (string, error)
func NewCluster ¶
func OpNameFromContext ¶
func PrepareArgs ¶
func SerializeListInterface ¶
func StartSpanFromParent ¶
func VertexesMatch ¶
Types ¶
type AuthInfo ¶
AuthInfo includes all info related with SASL authentication with the Gremlin server ChallengeId is the requestID in the 407 status (AUTHENTICATE) response given by the server. We have to send an authentication request with that same RequestID in order to solve the challenge.
func NewAuthInfo ¶
Constructor for different authentication possibilities
type CleanEdge ¶
func ConvertToCleanEdges ¶
type CleanResponse ¶
type CleanResponse struct { V []CleanVertex E []CleanEdge }
type CleanVertex ¶
func ConvertToCleanVertexes ¶
func ConvertToCleanVertexes(vertexes Vertexes) []CleanVertex
type EdIdType ¶ added in v1.0.7
type EdIdType struct { Type string `json:"@type"` Value EdgeIdValueType `json:"@value"` }
type Edge ¶
func MakeDummyEdge ¶
type EdgeIdValueType ¶ added in v1.0.7
type EdgeIdValueType struct {
RelationId string
}
type EdgeProperty ¶
type EdgeProperty struct { Type string `json:"@type"` Value EdgePropertyValue `json:"@value"` }
func MakeDummyProperty ¶
func MakeDummyProperty(label string, value interface{}) EdgeProperty
type EdgePropertyValue ¶
type EdgePropertyValue struct { Label string `json:"key"` Value interface{} `json:"value"` }
type EdgeV2 ¶ added in v1.0.8
type EdgeV2 struct { Type string `json:"@type"` Value EdgeValueV2 `json:"@value"` }
type EdgeValueType ¶ added in v1.0.10
type EdgeValueV2 ¶ added in v1.0.7
type EdgeValueV2 struct { ID EdIdType Label string InVLabel string OutVLabel string InV EdgeValueType OutV EdgeValueType Properties map[string]EdgeProperty }
type FormattedReq ¶
type FormattedReq struct { Op string `json:"op"` RequestId interface{} `json:"requestId"` Args *RequestArgs `json:"args"` Processor string `json:"processor"` }
Formats the requests in the appropriate way
func NewFormattedReq ¶
func NewFormattedReq(req *Request) FormattedReq
type GenericValue ¶
type GenericValue struct { Type string `json:"@type"` Value interface{} `json:"@value"` }
func MakeDummyGenericValue ¶
func MakeDummyGenericValue(gvType string, value interface{}) GenericValue
func (GenericValue) Equals ¶
func (g1 GenericValue) Equals(g2 GenericValue) bool
type GenericValues ¶
type GenericValues []GenericValue
func SerializeGenericValues ¶
func SerializeGenericValues(rawResponse string) (GenericValues, error)
type GremlinClient ¶
type GremlinClient struct { LockClient lock.LockClient_i // contains filtered or unexported fields }
func NewGremlinClient ¶
func NewGremlinClient(urlStr string, maxCap int, maxRetries int, verboseLogging bool, lockClient lock.LockClient_i, options ...OptAuth) (*GremlinClient, error)
func (*GremlinClient) ExecQueryF ¶
func (c *GremlinClient) ExecQueryF(ctx context.Context, gremlinQuery GremlinQuery) (string, error)
func (*GremlinClient) StartMonitor ¶
type GremlinConnection ¶
type GremlinConnection struct { Remote *url.URL Ws *websocket.Conn Auth []OptAuth VerboseLogging bool }
GremlinConnections include the necessary info to connect to the server and the underlying socket
func NewGremlinConnection ¶
func NewGremlinConnection(urlStr string, options ...OptAuth) (*GremlinConnection, error)
func NewVerboseGremlinConnection ¶
func NewVerboseGremlinConnection(urlStr string, verboseLogging bool, options ...OptAuth) (*GremlinConnection, error)
func (*GremlinConnection) Authenticate ¶
func (c *GremlinConnection) Authenticate(requestId string) ([]byte, error)
Authenticates the connection
func (*GremlinConnection) Close ¶
func (c *GremlinConnection) Close() error
func (*GremlinConnection) ExecQuery ¶
func (c *GremlinConnection) ExecQuery(query string) ([]byte, error)
GremlinConnection executes the provided request
func (*GremlinConnection) MaintainConnection ¶
func (c *GremlinConnection) MaintainConnection(urlStr string) error
Send a dummy query to neptune If there is a network error, attempt to reconnect
func (*GremlinConnection) ReadResponse ¶
func (c *GremlinConnection) ReadResponse() (data []byte, err error)
func (*GremlinConnection) Reconnect ¶
func (c *GremlinConnection) Reconnect(urlStr string) error
func (*GremlinConnection) SetLogVerbosity ¶
func (c *GremlinConnection) SetLogVerbosity(verboseLogging bool)
type GremlinInstr ¶
type GremlinInstr struct {
// contains filtered or unexported fields
}
func NewGremlinInstr ¶
func NewGremlinInstr(next Gremlin_i, instr InstrumentationProvider_i) GremlinInstr
func (GremlinInstr) ExecQueryF ¶
func (g GremlinInstr) ExecQueryF(ctx context.Context, gremlinQuery GremlinQuery) (response string, err error)
func (GremlinInstr) StartMonitor ¶
type GremlinLogger ¶
type GremlinLogger struct {
// contains filtered or unexported fields
}
func NewGremlinLogger ¶
func NewGremlinLogger(next Gremlin_i, logger Logger_i) GremlinLogger
func (GremlinLogger) ExecQueryF ¶
func (g GremlinLogger) ExecQueryF(ctx context.Context, gremlinQuery GremlinQuery) (response string, err error)
func (GremlinLogger) StartMonitor ¶
type GremlinQuery ¶
type GremlinResponse ¶
type GremlinResponse struct { V VertexesV2 E Edges }
cbi made up, not a real graphson or gremlin thing
type GremlinStackOptions ¶
type GremlinStackOptions struct { MaxCap int MaxRetries int VerboseLogging bool PingInterval int Logger Logger_i Tracer opentracing.Tracer Instr InstrumentationProvider_i LockClient lock.LockClient_i }
type GremlinTracer ¶
type GremlinTracer struct {
// contains filtered or unexported fields
}
func NewGremlinTracer ¶
func NewGremlinTracer(next Gremlin_i, tracer opentracing.Tracer) GremlinTracer
func (GremlinTracer) ExecQueryF ¶
func (g GremlinTracer) ExecQueryF(ctx context.Context, gremlinQuery GremlinQuery) (response string, err error)
func (GremlinTracer) StartMonitor ¶
type Gremlin_i ¶
type Gremlin_i interface { ExecQueryF(ctx context.Context, gremlinQuery GremlinQuery) (response string, err error) StartMonitor(ctx context.Context, interval time.Duration) (err error) Close(ctx context.Context) (err error) }
func NewGremlinStack ¶
func NewGremlinStack(urlStr string, gremlinStackOptions GremlinStackOptions, authOptions ...OptAuth) (Gremlin_i, error)
type IdType ¶ added in v1.0.4
type IdType IdTypeStruct
type IdTypeStruct ¶ added in v1.0.4
type OptAuth ¶
func OptAuthEnv ¶
func OptAuthEnv() OptAuth
Sets authentication info from environment variables GREMLIN_USER and GREMLIN_PASS
func OptAuthUserPass ¶
Sets authentication information from username and password
type Request ¶
type Request struct { RequestId string `json:"requestId"` Op string `json:"op"` Processor string `json:"processor"` Args *RequestArgs `json:"args"` }
func (*Request) ManageTransaction ¶
func (*Request) SetProcessor ¶
type RequestArgs ¶
type RequestArgs struct { Gremlin string `json:"gremlin,omitempty"` Session string `json:"session,omitempty"` Bindings Bind `json:"bindings,omitempty"` Language string `json:"language,omitempty"` Rebindings Bind `json:"rebindings,omitempty"` Sasl string `json:"sasl,omitempty"` BatchSize int `json:"batchSize,omitempty"` ManageTransaction bool `json:"manageTransaction,omitempty"` Aliases map[string]string `json:"aliases,omitempty"` }
type Response ¶
type Response struct { RequestId string `json:"requestId"` Status *ResponseStatus `json:"status"` Result *ResponseResult `json:"result"` }
type ResponseResult ¶
type ResponseResult struct { Data json.RawMessage `json:"data"` Meta map[string]interface{} `json:"meta"` }
type ResponseStatus ¶
type Vertex ¶
type Vertex struct { Type string `json:"@type"` Value VertexValue `json:"@value"` }
func MakeDummyVertex ¶
type VertexProperty ¶
type VertexProperty struct { Type string `json:"@type"` Value VertexPropertyValue `json:"@value"` }
func MakeDummyVertexProperty ¶
func MakeDummyVertexProperty(label string, value interface{}) VertexProperty
func (VertexProperty) Equals ¶
func (v1 VertexProperty) Equals(v2 VertexProperty) bool
type VertexPropertyValue ¶
type VertexPropertyValue struct { ID GenericValue `json:"id"` Label string `json:"label"` Value interface{} `json:"value"` }
func (VertexPropertyValue) Equals ¶
func (v1 VertexPropertyValue) Equals(v2 VertexPropertyValue) bool
type VertexV2 ¶ added in v1.0.6
type VertexV2 struct { Type string `json:"@type"` Value VertexValueV2 `json:"@value"` }
type VertexValue ¶
type VertexValue struct { ID string `json:"id"` Label string `json:"label"` Properties map[string][]VertexProperty `json:"properties"` }
func (VertexValue) Equals ¶
func (v1 VertexValue) Equals(v2 VertexValue) bool
type VertexValueV2 ¶ added in v1.0.6
type VertexValueV2 struct { ID IdType `json:"id"` Label string `json:"label"` Properties map[string][]VertexProperty `json:"properties"` }
type VertexesV2 ¶ added in v1.0.6
type VertexesV2 []VertexV2
func DeserializeVerticesV2 ¶ added in v1.0.6
func DeserializeVerticesV2(rawResponse string) (VertexesV2, error)