interfaces

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

View Source
const (
	StatusSuccess                  = 200
	StatusNoContent                = 204
	StatusPartialContent           = 206
	StatusUnauthorized             = 401
	StatusAuthenticate             = 407
	StatusMalformedRequest         = 498
	StatusInvalidRequestArguments  = 499
	StatusServerError              = 500
	StatusScriptEvaluationError    = 597
	StatusServerTimeout            = 598
	StatusServerSerializationError = 599
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncResponse

type AsyncResponse struct {
	Response     Response `json:"response"`     //Partial Response object
	ErrorMessage string   `json:"errorMessage"` // Error message if there was an error
}

AsyncResponse structs holds the entire response from requests to the gremlin server

type Counter

type Counter interface {
	// Count adds .count(), to the query. The query call will return the number of entities found in the query.
	Count() QueryBuilder
}

type Dialer

type Dialer interface {
	Connect() error
	IsConnected() bool
	Write([]byte) error
	Read() (int, []byte, error)
	Close() error
	Ping() error
}

Dialer represents a entity that is able to open a websocket and work (read/ write) on it.

type Dropper

type Dropper interface {
	// Drop adds .drop(), to the query. The query call will drop/ delete all referenced entities
	Drop() QueryBuilder
}

type Edge

type Edge interface {
	QueryBuilder
	Dropper
	Profiler
	Counter

	// To adds .to(<vertex>), to the query. The query call will be the second step to add an edge
	To(v Vertex) Edge
	// From adds .from(<vertex>), to the query. The query call will be the second step to add an edge
	From(v Vertex) Edge

	// OutV adds .outV(), to the query. The query call will return the vertices on the outgoing side of this edge
	OutV() Vertex
	// InV adds .inV(), to the query. The query call will return the vertices on the incoming side of this edge
	InV() Vertex
	// Add can be used to add a custom QueryBuilder
	// e.g. g.V().Add(NewSimpleQB(".myCustomCall('%s')",label))
	Add(builder QueryBuilder) Edge

	// HasLabel adds .hasLabel([<label_1>,<label_2>,..,<label_n>]), e.g. .hasLabel('user','name'), to the query. The query call returns all edges with the given label.
	HasLabel(label ...string) Edge
}

type Graph

type Graph interface {
	QueryBuilder

	// V adds .V() to the query. The query call returns all vertices.
	V() Vertex
	// VBy adds .V(<id>), e.g. .V(123), to the query. The query call returns the vertex with the given id.
	VBy(id int) Vertex
	// VByUUID adds .V(<id>), e.g. .V('8fff9259-09e6-4ea5-aaf8-250b31cc7f44'), to the query. The query call returns the vertex with the given id.
	VByUUID(id uuid.UUID) Vertex
	// VByStr adds .V(<id>), e.g. .V("123a"), to the query.  The query call returns the vertex with the given id.
	VByStr(id string) Vertex
	// AddV adds .addV('<label>'), e.g. .addV('user'), to the query. The query call adds a vertex with the given label and returns that vertex.
	AddV(label string) Vertex
	// E adds .E() to the query. The query call returns all edges.
	E() Edge
}

Graph represents a QueryBuilder that can be used to create queries on graph level

type Profiler

type Profiler interface {
	// Profile adds .executionProfile(), to the query. The query call will return profiling information of the executed query
	Profile() QueryBuilder
}

type QueryBuilder

type QueryBuilder interface {
	String() string
}

QueryBuilder can be used to generate queries for the cosmos db

type QueryExecutor

type QueryExecutor interface {
	Close() error
	IsConnected() bool
	LastError() error
	Execute(query string) (resp []Response, err error)
	ExecuteAsync(query string, responseChannel chan AsyncResponse) (err error)
	ExecuteFileWithBindings(path string, bindings, rebindings map[string]string) (resp []Response, err error)
	ExecuteFile(path string) (resp []Response, err error)
	ExecuteWithBindings(query string, bindings, rebindings map[string]string) (resp []Response, err error)
	Ping() error
}

type Response

type Response struct {
	RequestID string `json:"requestId"`
	Status    Status `json:"status"`
	Result    Result `json:"result"`
}

Response structs holds the entire response from requests to the gremlin server

func (Response) String

func (r Response) String() string

String returns a string representation of the Response struct

type Result

type Result struct {
	// Query Response Data
	Data json.RawMessage        `json:"data"`
	Meta map[string]interface{} `json:"meta"`
}

Result struct is used to hold properties returned for results from requests to the gremlin server

type Status

type Status struct {
	Message    string                 `json:"message"`
	Code       int                    `json:"code"`
	Attributes map[string]interface{} `json:"attributes"`
}

Status struct is used to hold properties returned from requests to the gremlin server

type Vertex

type Vertex interface {
	QueryBuilder
	Dropper
	Profiler
	Counter

	// HasLabel adds .hasLabel([<label_1>,<label_2>,..,<label_n>]), e.g. .hasLabel('user','name'), to the query. The query call returns all vertices with the given label.
	HasLabel(vertexLabel ...string) Vertex
	// Property adds .property('<key>','<value>'), e.g. .property('name','hans'), to the query. The query call will add the given property.
	Property(key, value string) Vertex
	// PropertyInt adds .property('<key>',<int value>), e.g. .property('age',55), to the query. The query call will add the given property.
	PropertyInt(key string, value int) Vertex
	// PropertyList adds .property(list,'<key>','<value>'), e.g. .property(list, 'name','hans'), to the query. The query call will add the given property.
	PropertyList(key, value string) Vertex
	// Properties adds .properties(), to the query. The query call returns all properties of the vertex.
	Properties() QueryBuilder
	// Has adds .has('<key>','<value>'), e.g. .has('name','hans'), to the query. The query call returns all vertices
	// with the property which is defined by the given key value pair.
	Has(key, value string) Vertex
	// Has adds .has('<key>',<int value>), e.g. .has('age',55), to the query. The query call returns all vertices
	// with the property which is defined by the given key value pair.
	HasInt(key string, value int) Vertex
	// ValuesBy adds .values('<label>'), e.g. .values('user'), to the query. The query call returns all values of the vertex.
	ValuesBy(label string) QueryBuilder
	// Values adds .values(), to the query. The query call returns all values with the given label of the vertex.
	Values() QueryBuilder
	// ValueMap adds .valueMap(), to the query. The query call returns all values as a map of the vertex.
	ValueMap() QueryBuilder
	// Add can be used to add a custom QueryBuilder
	// e.g. g.V().Add(NewSimpleQB(".myCustomCall('%s')",label))
	Add(builder QueryBuilder) Vertex
	// Id adds .id(), to the query. The query call returns the id of the vertex.
	Id() QueryBuilder

	// AddE adds .addE(<label>), to the query. The query call will be the first step to add an edge
	AddE(label string) Edge

	// OutE adds .outE([<label_1>,<label_2>,..,<label_n>]), to the query. The query call returns all outgoing edges of the Vertex
	OutE(labels ...string) Edge

	// InE adds .inE([<label_1>,<label_2>,..,<label_n>]), to the query. The query call returns all incoming edges of the Vertex
	InE(labels ...string) Edge
}

Vertex represents a QueryBuilder that can be used to create queries on vertex level

type WebsocketConnection

type WebsocketConnection interface {
	SetPongHandler(handler func(appData string) error)
	WriteMessage(messageType int, data []byte) error
	ReadMessage() (messageType int, p []byte, err error)
	Close() error
	WriteControl(messageType int, data []byte, deadline time.Time) error
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
}

WebsocketConnection is the minimal interface needed to act on a websocket

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL