forked from go-gremlin/gremlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
request.go
45 lines (39 loc) · 1014 Bytes
/
request.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package gremlin
import (
"github.com/satori/go.uuid"
)
type Request struct {
RequestId string `json:"requestId"`
Op string `json:"op"`
Processor string `json:"processor"`
Args *RequestArgs `json:"args"`
conn *Conn
}
type RequestArgs struct {
Gremlin string `json:"gremlin,omitempty"`
Session string `json:"session,omitempty"`
Bindings Bind `json:"bindings,omitempty"`
Language string `json:"language,omitempty"`
Rebindings Bind `json:"rebindings,omitempty"`
Sasl []byte `json:"sasl,omitempty"`
BatchSize int `json:"batchSize,omitempty"`
}
type Bind map[string]interface{}
func (c *Conn) Query(query string) *Request {
args := &RequestArgs{
Gremlin: query,
Language: "gremlin-groovy",
}
req := &Request{
RequestId: uuid.NewV4().String(),
Op: "eval",
Processor: "",
Args: args,
conn: c,
}
return req
}
func (req *Request) Bindings(bindings Bind) *Request {
req.Args.Bindings = bindings
return req
}