forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_tcp_info_command.go
52 lines (42 loc) · 1.05 KB
/
get_tcp_info_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
49
50
51
52
package ravendb
import (
"net/http"
)
var (
_ RavenCommand = &GetTcpInfoCommand{}
)
// GetTcpInfoCommand describes "get tcp info" command
type GetTcpInfoCommand struct {
RavenCommandBase
tag string
dbName string
requestedNode *ServerNode
Result *TcpConnectionInfo
}
// NewGetTcpInfoCommand returns new GetTcpInfoCommand
// dbName is optional
func NewGetTcpInfoCommand(tag, dbName string) *GetTcpInfoCommand {
cmd := &GetTcpInfoCommand{
RavenCommandBase: NewRavenCommandBase(),
tag: tag,
dbName: dbName,
}
cmd.IsReadRequest = true
return cmd
}
func (c *GetTcpInfoCommand) CreateRequest(node *ServerNode) (*http.Request, error) {
url := ""
if c.dbName == "" {
url = node.URL + "/info/tcp?tcp=" + c.tag
} else {
url = node.URL + "/databases/" + c.dbName + "/info/tcp?tag=" + c.tag
}
c.requestedNode = node
return newHttpGet(url)
}
func (c *GetTcpInfoCommand) SetResponse(response []byte, fromCache bool) error {
if len(response) == 0 {
return throwInvalidResponse()
}
return jsonUnmarshal(response, &c.Result)
}