forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhi_lo_return_command.go
48 lines (39 loc) · 1.04 KB
/
hi_lo_return_command.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
46
47
48
package ravendb
import (
"net/http"
)
var (
_ RavenCommand = &HiLoReturnCommand{}
)
// HiLoReturnCommand represents "hi lo return" command
type HiLoReturnCommand struct {
RavenCommandBase
tag string
last int64
end int64
}
// NewHiLoReturnCommand returns a new HiLoReturnCommand
func NewHiLoReturnCommand(tag string, last int64, end int64) (*HiLoReturnCommand, error) {
if last < 0 {
return nil, newIllegalArgumentError("last is < 0")
}
if end < 0 {
return nil, newIllegalArgumentError("end is < 0")
}
if tag == "" {
return nil, newIllegalArgumentError("tag cannot be empty")
}
cmd := &HiLoReturnCommand{
RavenCommandBase: NewRavenCommandBase(),
tag: tag,
last: last,
end: end,
}
cmd.IsReadRequest = true
cmd.ResponseType = RavenCommandResponseTypeEmpty
return cmd, nil
}
func (c *HiLoReturnCommand) CreateRequest(node *ServerNode) (*http.Request, error) {
url := node.URL + "/databases/" + node.Database + "/hilo/return?tag=" + c.tag + "&end=" + i64toa(c.end) + "&last=" + i64toa(c.last)
return newHttpPut(url, nil)
}