gremji

package module
v0.0.0-...-0cd7cf9 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2018 License: MIT Imports: 8 Imported by: 0

README

Gremji

Gremji is a Go driver to use with Gremlin in graph databases.

About the name

The name comes from the Blizzard's Overwatch character, Genji. It's a mix of the names Gremlin and Genji.

Motivation and main focus

We couldn't be able to find a maintained and useful driver for Go to use in our products. The main focus of this project is to run on top of Apache Tinkerpop.

Contributing

We're working on our contributing guidelines. Meanwhile any PR is welcome and will be analyzed.

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

View Source
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 GraphSONSerializer

func GraphSONSerializer(req *Request) ([]byte, error)

Types

type Bind

type Bind map[string]interface{}

type Client

type Client struct {
	Remote *url.URL
	Ws     *websocket.Conn
}

func NewClient

func NewClient(urlStr string) (*Client, error)

func (*Client) Exec

func (c *Client) Exec(req *Request) (*Response, error)

func (*Client) ExecQuery

func (c *Client) ExecQuery(query QueryArgs) (*Response, error)

func (*Client) ReadResponse

func (c *Client) ReadResponse() (*Response, error)

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 QueryArgs

type QueryArgs struct {
	Query      string
	Bindings   Bind
	Rebindings Bind
}

type Request

type Request struct {
	RequestId string       `json:"requestId"`
	Op        string       `json:"op"`
	Processor string       `json:"processor"`
	Args      *RequestArgs `json:"args"`
}

func Query

func Query(query QueryArgs) *Request

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"`
	Accept            string            `json:"accept,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"`
}

func (Response) ToString

func (r Response) ToString() string

type ResponseResult

type ResponseResult struct {
	Data json.RawMessage        `json:"data"`
	Meta map[string]interface{} `json:"meta"`
}

type ResponseStatus

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

Jump to

Keyboard shortcuts

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