Documentation ¶
Overview ¶
Package gremconnect has the connection related structs and functions.
Functions in this package relate to authentication and connection to the graph database of choice.
This package also includes the available dialers to use for the Grammes client such as the websocket dialer.
Index ¶
- Variables
- func PackageRequest(req Request, versionNumber string) (msg []byte, err error)
- type Auth
- type AuthInfo
- type Dialer
- type OptAuth
- type Request
- type Response
- type WebSocket
- func (ws *WebSocket) Address() string
- func (ws *WebSocket) Auth() (*Auth, error)
- func (ws *WebSocket) Close() error
- func (ws *WebSocket) Connect() error
- func (ws *WebSocket) GetQuit() chan struct{}
- func (ws *WebSocket) IsConnected() bool
- func (ws *WebSocket) IsDisposed() bool
- func (ws *WebSocket) Ping(errs chan error)
- func (ws *WebSocket) Read() (msg []byte, err error)
- func (ws *WebSocket) SetAuth(user, pass string)
- func (ws *WebSocket) SetPingInterval(interval time.Duration)
- func (ws *WebSocket) SetReadingWait(interval time.Duration)
- func (ws *WebSocket) SetTimeout(interval time.Duration)
- func (ws *WebSocket) SetWritingWait(interval time.Duration)
- func (ws *WebSocket) Write(msg []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( // GenUUID is a monkey patched function for the Google UUIDv4 generator. GenUUID = uuid.NewUUID )
Functions ¶
Types ¶
type AuthInfo ¶
AuthInfo holds all the information needed to use SASL authentication with the Gremlin server. ChallengeID is the requestID in the 407 status (AUTHENTICATE) response
type Dialer ¶
type Dialer interface { // Actions Connect() error Close() error Write(msg []byte) error Read() (msg []byte, err error) Ping(errs chan error) // Checkers IsConnected() bool IsDisposed() bool // Getters Auth() (*Auth, error) Address() string GetQuit() chan struct{} // Configuration Setters SetAuth(username string, password string) SetTimeout(interval time.Duration) SetPingInterval(interval time.Duration) SetWritingWait(interval time.Duration) SetReadingWait(interval time.Duration) }
Dialer will be used to dial in a connection between the client and gremlin server without directly using a websocket. This leaves room for mocking and altered methods of connecting to the server.
func NewWebSocketDialer ¶
NewWebSocketDialer returns a new WebSocket dialer to use when establishing a connection to the Gremlin server. This function also assigns default values to the websocket if they're not assigned by DialerConfig functions.
type OptAuth ¶
OptAuth holds data about the authentication
func OptAuthEnv ¶
func OptAuthEnv() OptAuth
OptAuthEnv sets authentication info from environment variables GREMLIN_USER and GREMLIN_PASS
func OptAuthUserPass ¶
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 map[string]interface{} `json:"args"` }
Request is a container for all evaluation request parameters to be sent to the Gremlin Server.
type Response ¶
Response is the structure representation of the response json received from the Gremlin-Server.
func MarshalResponse ¶
MarshalResponse creates a Response struct for every incoming Response for further manipulation
type WebSocket ¶
WebSocket will hold all of the data used to dial to the gremlin server and sustain a stable connection by pinging it regularly.
func (*WebSocket) Auth ¶
Auth returns the websocket's authentication information if it's on a secure connection.
func (*WebSocket) Close ¶
Close disposes the websocket and closes the quit channel to signal the websocket's ping selection.
func (*WebSocket) Connect ¶
Connect will setup the gorilla websocket and other configurations to establish a connection to the given address.
func (*WebSocket) GetQuit ¶
func (ws *WebSocket) GetQuit() chan struct{}
GetQuit returns the quit channel so the websocket can communicate to the client that the connection has quit.
func (*WebSocket) IsConnected ¶
IsConnected returns whether the given websocket has an established connection.
func (*WebSocket) IsDisposed ¶
IsDisposed returns whether the given websocket has been disposed of its use.
func (*WebSocket) Ping ¶
Ping runs a routine ping check to the established connection and sends error channel a signal if there's a detected error if not/how the server responds.
func (*WebSocket) Read ¶
Read uses the gorilla function to read a response from the established connection.
func (*WebSocket) SetPingInterval ¶
SetPingInterval sets how often the websocket will ping the server.
func (*WebSocket) SetReadingWait ¶
SetReadingWait sets how long the reading will wait
func (*WebSocket) SetTimeout ¶
SetTimeout will set the dialing timeout
func (*WebSocket) SetWritingWait ¶
SetWritingWait sets how long the wait is for waiting