Skip to content
This repository has been archived by the owner on Aug 14, 2019. It is now read-only.

Commit

Permalink
Merge pull request #4 from schwartzmx/gomod
Browse files Browse the repository at this point in the history
swap to go mod, make isconnected and isdisposed public
  • Loading branch information
schwartzmx committed Jun 7, 2019
2 parents 6ee72bf + 9b19830 commit a89dc0c
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 82 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
vendor/


gremgo-neptune
16 changes: 9 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
language: go

env:
- DEP_VERSION="0.4.1"
go:
- 1.11.x
- master

before_script:
- go vet ./...

before_install:
- curl -L -s https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 -o $GOPATH/bin/dep
- chmod +x $GOPATH/bin/dep
env:
- GO111MODULE=on

install:
- dep ensure
install: true
21 changes: 0 additions & 21 deletions Gopkg.lock

This file was deleted.

38 changes: 0 additions & 38 deletions Gopkg.toml

This file was deleted.

6 changes: 3 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (c *Client) authenticate(requestID string) (err error) {

// ExecuteWithBindings formats a raw Gremlin query, sends it to Gremlin Server, and returns the result.
func (c *Client) ExecuteWithBindings(query string, bindings, rebindings map[string]string) (resp []Response, err error) {
if c.conn.isDisposed() {
if c.conn.IsDisposed() {
return resp, errors.New("you cannot write on disposed connection")
}
resp, err = c.executeRequest(query, &bindings, &rebindings)
Expand All @@ -121,7 +121,7 @@ func (c *Client) ExecuteWithBindings(query string, bindings, rebindings map[stri

// Execute formats a raw Gremlin query, sends it to Gremlin Server, and returns the result.
func (c *Client) Execute(query string) (resp []Response, err error) {
if c.conn.isDisposed() {
if c.conn.IsDisposed() {
return resp, errors.New("you cannot write on disposed connection")
}
resp, err = c.executeRequest(query, nil, nil)
Expand All @@ -130,7 +130,7 @@ func (c *Client) Execute(query string) (resp []Response, err error) {

// ExecuteFile takes a file path to a Gremlin script, sends it to Gremlin Server, and returns the result.
func (c *Client) ExecuteFile(path string, bindings, rebindings map[string]string) (resp []Response, err error) {
if c.conn.isDisposed() {
if c.conn.IsDisposed() {
return resp, errors.New("you cannot write on disposed connection")
}
d, err := ioutil.ReadFile(path) // Read script from file
Expand Down
10 changes: 6 additions & 4 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

type dialer interface {
connect() error
isConnected() bool
isDisposed() bool
IsConnected() bool
IsDisposed() bool
write([]byte) error
read() (int, []byte, error)
close() error
Expand Down Expand Up @@ -73,11 +73,13 @@ func (ws *Ws) connect() (err error) {
return
}

func (ws *Ws) isConnected() bool {
// IsConnected returns whether the underlying websocket is connected
func (ws *Ws) IsConnected() bool {
return ws.connected
}

func (ws *Ws) isDisposed() bool {
// IsDisposed returns whether the underlying websocket is disposed
func (ws *Ws) IsDisposed() bool {
return ws.disposed
}

Expand Down
7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module gremgo

require (
github.com/gorilla/websocket v1.2.0
github.com/pkg/errors v0.8.1
github.com/satori/go.uuid v1.2.0
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ=
github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
12 changes: 3 additions & 9 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/base64"
"encoding/json"

"github.com/satori/go.uuid"
uuid "github.com/satori/go.uuid"
)

type requester interface {
Expand All @@ -24,10 +24,7 @@ type request struct {
// prepareRequest packages a query and binding into the format that Gremlin Server accepts
func prepareRequest(query string) (req request, id string, err error) {
var uuID uuid.UUID
uuID, err = uuid.NewV4()
if err != nil {
return
}
uuID = uuid.NewV4()
id = uuID.String()

req.RequestID = id
Expand All @@ -44,10 +41,7 @@ func prepareRequest(query string) (req request, id string, err error) {
// prepareRequest packages a query and binding into the format that Gremlin Server accepts
func prepareRequestWithBindings(query string, bindings, rebindings map[string]string) (req request, id string, err error) {
var uuID uuid.UUID
uuID, err = uuid.NewV4()
if err != nil {
return
}
uuID = uuid.NewV4()
id = uuID.String()

req.RequestID = id
Expand Down

0 comments on commit a89dc0c

Please sign in to comment.