Documentation ¶
Index ¶
- Constants
- Variables
- func GremlinForVertex(label string, data interface{}) (gremAdd, gremGet string, err error)
- type Client
- func (c *Client) AddE(label, fromId, toId string, props map[string]interface{}) (resp interface{}, err error)
- func (c *Client) AddEdgeCtx(ctx context.Context, label, fromId, toId string, props map[string]interface{}) (resp interface{}, err error)
- func (c *Client) AddV(label string, data interface{}, bindings, rebindings map[string]string) (vert graphson.Vertex, err error)
- func (c *Client) AddVertexCtx(ctx context.Context, label string, data interface{}, ...) (vert graphson.Vertex, err error)
- func (c *Client) Close()
- func (c *Client) Execute(query string, bindings, rebindings map[string]string) (resp []Response, err error)
- func (c *Client) ExecuteCtx(ctx context.Context, query string, bindings, rebindings map[string]string) (resp []Response, err error)
- func (c *Client) ExecuteFile(path string, bindings, rebindings map[string]string) (resp []Response, err error)
- func (c *Client) Get(query string, bindings, rebindings map[string]string) (res []graphson.Vertex, err error)
- func (c *Client) GetCount(query string, bindings, rebindings map[string]string) (i int64, err error)
- func (c *Client) GetCountCtx(ctx context.Context, query string, bindings, rebindings map[string]string) (i int64, err error)
- func (c *Client) GetCtx(ctx context.Context, query string, bindings, rebindings map[string]string) (res []graphson.Vertex, err error)
- func (c *Client) GetE(query string, bindings, rebindings map[string]string) (res []graphson.Edge, err error)
- func (c *Client) GetEdgeCtx(ctx context.Context, query string, bindings, rebindings map[string]string) (res []graphson.Edge, err error)
- func (c *Client) GetProperties(query string, bindings, rebindings map[string]string) (vals map[string][]interface{}, err error)
- func (c *Client) GetPropertiesCtx(ctx context.Context, query string, bindings, rebindings map[string]string) (vals map[string][]interface{}, err error)
- func (c *Client) GetStringList(query string, bindings, rebindings map[string]string) (vals []string, err error)
- func (c *Client) GetStringListCtx(ctx context.Context, query string, bindings, rebindings map[string]string) (vals []string, err error)
- func (c *Client) OpenCursorCtx(ctx context.Context, query string, bindings, rebindings map[string]string) (cursor *Cursor, err error)
- func (c *Client) OpenStreamCursor(ctx context.Context, query string, bindings, rebindings map[string]string) (*Stream, error)
- func (c *Client) ReadCursorCtx(ctx context.Context, cursor *Cursor) (res []graphson.Vertex, eof bool, err error)
- type Cursor
- type DialerConfig
- func SetAuthentication(username string, password string) DialerConfig
- func SetPingInterval(seconds int) DialerConfig
- func SetReadingWait(seconds int) DialerConfig
- func SetTLSClientConfig(conf *tls.Config) DialerConfig
- func SetTimeout(seconds int) DialerConfig
- func SetWritingWait(seconds int) DialerConfig
- type Pool
- func (p *Pool) AddE(label, fromId, toId string, props map[string]interface{}) (resp interface{}, err error)
- func (p *Pool) AddEdgeCtx(ctx context.Context, label, fromId, toId string, props map[string]interface{}) (resp interface{}, err error)
- func (p *Pool) AddV(label string, i interface{}, bindings, rebindings map[string]string) (resp graphson.Vertex, err error)
- func (p *Pool) AddVertexCtx(ctx context.Context, label string, i interface{}, ...) (resp graphson.Vertex, err error)
- func (p *Pool) Close()
- func (p *Pool) Execute(query string, bindings, rebindings map[string]string) (resp []Response, err error)
- func (p *Pool) ExecuteCtx(ctx context.Context, query string, bindings, rebindings map[string]string) (resp []Response, err error)
- func (p *Pool) ExecuteFile(path string, bindings, rebindings map[string]string) (resp []Response, err error)
- func (p *Pool) Get(query string, bindings, rebindings map[string]string) (resp []graphson.Vertex, err error)
- func (p *Pool) GetCount(q string, bindings, rebindings map[string]string) (i int64, err error)
- func (p *Pool) GetCountCtx(ctx context.Context, q string, bindings, rebindings map[string]string) (i int64, err error)
- func (p *Pool) GetCtx(ctx context.Context, query string, bindings, rebindings map[string]string) (resp []graphson.Vertex, err error)
- func (p *Pool) GetE(q string, bindings, rebindings map[string]string) (resp interface{}, err error)
- func (p *Pool) GetEdgeCtx(ctx context.Context, q string, bindings, rebindings map[string]string) (resp interface{}, err error)
- func (p *Pool) GetProperties(q string, bindings, rebindings map[string]string) (vals map[string][]interface{}, err error)
- func (p *Pool) GetPropertiesCtx(ctx context.Context, q string, bindings, rebindings map[string]string) (vals map[string][]interface{}, err error)
- func (p *Pool) GetStringList(q string, bindings, rebindings map[string]string) (vals []string, err error)
- func (p *Pool) GetStringListCtx(ctx context.Context, q string, bindings, rebindings map[string]string) (vals []string, err error)
- func (p *Pool) OpenCursorCtx(ctx context.Context, query string, bindings, rebindings map[string]string) (cursor *Cursor, err error)
- func (p *Pool) OpenStreamCursor(ctx context.Context, query string, bindings, rebindings map[string]string) (stream *Stream, err error)
- func (p *Pool) ReadCursorCtx(ctx context.Context, cursor *Cursor) (res []graphson.Vertex, eof bool, err error)
- type Response
- type Result
- type Retriever
- type Status
- type Stream
- type Ws
Constants ¶
const ( StatusSuccess = 200 StatusNoContent = 204 StatusPartialContent = 206 StatusAuthenticate = 407 StatusMalformedRequest = 498 StatusInvalidRequestArguments = 499 StatusServerError = 500 StatusScriptEvaluationError = 597 StatusServerTimeout = 598 StatusServerSerializationError = 599 )
Variables ¶
var ( ErrorConnectionDisposed = errors.New("you cannot write on a disposed connection") ErrorNoGraphTags = errors.New("does not contain any graph tags") ErrorUnsupportedPropertyType = errors.New("unsupported property map value type") )
var ( ErrGraphDBClosed = errors.New("graphdb is closed") ErrBadConn = errors.New("bad conn") )
errors
Functions ¶
func GremlinForVertex ¶
GremlinForVertex returns the addV()... and V()... gremlin commands for `data` Because of possible multiples, it does not start with `g.` (it probably should? XXX ) (largely taken from https://github.com/intwinelabs/gremgoser)
Types ¶
type Client ¶
Client is a container for the gremgo client.
func Dial ¶
Dial returns a gremgo client for interaction with the Gremlin Server specified in the host IP.
func DialCtx ¶
DialCtx returns a gremgo client for interaction with the Gremlin Server specified in the host IP.
func (*Client) AddE ¶
func (c *Client) AddE(label, fromId, toId string, props map[string]interface{}) (resp interface{}, err error)
AddE takes a label, from UUID and to UUID (and optional props map) and creates an edge between the two vertex in the graph
func (*Client) AddEdgeCtx ¶
func (*Client) AddV ¶
func (c *Client) AddV(label string, data interface{}, bindings, rebindings map[string]string) (vert graphson.Vertex, err error)
AddV takes a label and an interface and adds it as a vertex to the graph
func (*Client) AddVertexCtx ¶
func (*Client) Close ¶
func (c *Client) Close()
Close closes the underlying connection and marks the client as closed.
func (*Client) Execute ¶
func (c *Client) Execute(query string, bindings, rebindings map[string]string) (resp []Response, err error)
Execute formats a raw Gremlin query, sends it to Gremlin Server, and returns the result.
func (*Client) ExecuteCtx ¶
func (*Client) ExecuteFile ¶
func (c *Client) ExecuteFile(path string, bindings, rebindings map[string]string) (resp []Response, err error)
ExecuteFile takes a file path to a Gremlin script, sends it to Gremlin Server, and returns the result.
func (*Client) Get ¶
func (c *Client) Get(query string, bindings, rebindings map[string]string) (res []graphson.Vertex, err error)
Get formats a raw Gremlin query, sends it to Gremlin Server, and populates the passed []interface.
func (*Client) GetCount ¶
func (c *Client) GetCount(query string, bindings, rebindings map[string]string) (i int64, err error)
GetCount returns the count element returned by an Execute()
func (*Client) GetCountCtx ¶
func (*Client) GetCtx ¶
func (c *Client) GetCtx(ctx context.Context, query string, bindings, rebindings map[string]string) (res []graphson.Vertex, err error)
GetCtx - execute a gremlin command and return the response as vertices
func (*Client) GetE ¶
func (c *Client) GetE(query string, bindings, rebindings map[string]string) (res []graphson.Edge, err error)
GetE formats a raw Gremlin query, sends it to Gremlin Server, and populates the passed []interface.
func (*Client) GetEdgeCtx ¶
func (*Client) GetProperties ¶
func (c *Client) GetProperties(query string, bindings, rebindings map[string]string) (vals map[string][]interface{}, err error)
GetProperties returns a map of string to interface{} returned by an Execute() for vertex .properties()
func (*Client) GetPropertiesCtx ¶
func (*Client) GetStringList ¶
func (c *Client) GetStringList(query string, bindings, rebindings map[string]string) (vals []string, err error)
GetStringList returns the list of string elements returned by an Execute() (e.g. from `...().properties('p').value()`)
func (*Client) GetStringListCtx ¶
func (*Client) OpenCursorCtx ¶
func (c *Client) OpenCursorCtx(ctx context.Context, query string, bindings, rebindings map[string]string) (cursor *Cursor, err error)
OpenCursorCtx initiates a query on the database, returning a cursor used to iterate over the results as they arrive. The provided query must return a vertex or list of vertices in order for ReadCursorCtx to correctly format the results.
func (*Client) OpenStreamCursor ¶
func (c *Client) OpenStreamCursor(ctx context.Context, query string, bindings, rebindings map[string]string) (*Stream, error)
OpenStreamCursor initiates a query on the database, returning a stream cursor used to iterate over the results as they arrive. The provided query must only return a string list, as the Read() function on Stream explicitly handles string values.
func (*Client) ReadCursorCtx ¶
func (c *Client) ReadCursorCtx(ctx context.Context, cursor *Cursor) (res []graphson.Vertex, eof bool, err error)
ReadCursorCtx returns the next set of results, deserialized as []Vertex, for the cursor - `res` may be empty when results were read by a previous call - `eof` will be true when no more results are available
type Cursor ¶
type Cursor struct {
ID string
}
Cursor allows for results to be iterated over as soon as available, rather than waiting for a query to complete and all results to be returned in one block.
type DialerConfig ¶
type DialerConfig func(*Ws)
DialerConfig is the struct for defining configuration for WebSocket dialer
func SetAuthentication ¶
func SetAuthentication(username string, password string) DialerConfig
SetAuthentication sets on dialer credentials for authentication
func SetPingInterval ¶
func SetPingInterval(seconds int) DialerConfig
SetPingInterval sets the interval of ping sending for know is connection is alive and in consequence the client is connected
func SetReadingWait ¶
func SetReadingWait(seconds int) DialerConfig
SetReadingWait sets the time for waiting that reading occur
func SetTLSClientConfig ¶ added in v1.1.0
func SetTLSClientConfig(conf *tls.Config) DialerConfig
SetTLSClientConfig sets the TLS client config for the underlying websocket connection
func SetWritingWait ¶
func SetWritingWait(seconds int) DialerConfig
SetWritingWait sets the time for waiting that writing occur
type Pool ¶
type Pool struct { MaxOpen int MaxLifetime time.Duration // contains filtered or unexported fields }
Pool maintains a list of connections.
func NewPoolWithDialerCtx ¶
func NewPoolWithDialerCtx(ctx context.Context, dbURL string, errs chan error, cfgs ...DialerConfig) *Pool
NewPoolWithDialerCtx returns a NewPool that uses a contextual dialer to dbURL, errs is a chan that receives any errors from the ping/read/write workers for the connection
func (*Pool) AddE ¶
func (p *Pool) AddE(label, fromId, toId string, props map[string]interface{}) (resp interface{}, err error)
AddE
func (*Pool) AddEdgeCtx ¶
func (*Pool) AddV ¶
func (p *Pool) AddV(label string, i interface{}, bindings, rebindings map[string]string) (resp graphson.Vertex, err error)
AddV
func (*Pool) AddVertexCtx ¶
func (*Pool) Execute ¶
func (p *Pool) Execute(query string, bindings, rebindings map[string]string) (resp []Response, err error)
Execute formats a raw Gremlin query, sends it to Gremlin Server, and returns the result.
func (*Pool) ExecuteCtx ¶
func (*Pool) ExecuteFile ¶
func (p *Pool) ExecuteFile(path string, bindings, rebindings map[string]string) (resp []Response, err error)
ExecuteFile takes a file path to a Gremlin script, sends it to Gremlin Server, and returns the result.
func (*Pool) Get ¶
func (p *Pool) Get(query string, bindings, rebindings map[string]string) (resp []graphson.Vertex, err error)
Get
func (*Pool) GetCountCtx ¶
func (*Pool) GetCtx ¶
func (p *Pool) GetCtx(ctx context.Context, query string, bindings, rebindings map[string]string) (resp []graphson.Vertex, err error)
GetCtx
func (*Pool) GetEdgeCtx ¶
func (*Pool) GetProperties ¶
func (p *Pool) GetProperties(q string, bindings, rebindings map[string]string) (vals map[string][]interface{}, err error)
GetProperties returns a map of vertex properties
func (*Pool) GetPropertiesCtx ¶
func (*Pool) GetStringList ¶
func (*Pool) GetStringListCtx ¶
func (*Pool) OpenCursorCtx ¶
func (p *Pool) OpenCursorCtx(ctx context.Context, query string, bindings, rebindings map[string]string) (cursor *Cursor, err error)
OpenCursorCtx initiates a query on the database, returning a cursor to iterate over the results
func (*Pool) OpenStreamCursor ¶
func (p *Pool) OpenStreamCursor(ctx context.Context, query string, bindings, rebindings map[string]string) (stream *Stream, err error)
OpenStreamCursor initiates a query on the database, returning a stream to iterate over the results
func (*Pool) ReadCursorCtx ¶
func (p *Pool) ReadCursorCtx(ctx context.Context, cursor *Cursor) (res []graphson.Vertex, eof bool, err error)
ReadCursorCtx returns the next set of results for the cursor - `res` returns vertices (and may be empty when results were read by a previous call - this is normal) - `eof` will be true when no more results are available (`res` may still have results)
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
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 Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream is a specific implementation of a Cursor, which iterates over results from a cursor but only works on queries which return a list of strings. This is designed for returning what would be considered 'rows' of data in other contexts.
type Ws ¶
Ws is the dialer for a WebSocket connection
func NewDialer ¶
func NewDialer(host string, configs ...DialerConfig) (dialer *Ws)
NewDialer returns a WebSocket dialer to use when connecting to Gremlin Server
func (*Ws) IsConnected ¶
IsConnected returns whether the underlying websocket is connected
func (*Ws) IsDisposed ¶
IsDisposed returns whether the underlying websocket is disposed