github.com/ravendb/ravendb-go-client@v0.0.0-20240229102137-4474ee7aa0fa/get_tcp_info_command.go (about) 1 package ravendb 2 3 import ( 4 "net/http" 5 ) 6 7 var ( 8 _ RavenCommand = &GetTcpInfoCommand{} 9 ) 10 11 // GetTcpInfoCommand describes "get tcp info" command 12 type GetTcpInfoCommand struct { 13 RavenCommandBase 14 15 tag string 16 dbName string 17 requestedNode *ServerNode 18 19 Result *TcpConnectionInfo 20 } 21 22 // NewGetTcpInfoCommand returns new GetTcpInfoCommand 23 // dbName is optional 24 func NewGetTcpInfoCommand(tag, dbName string) *GetTcpInfoCommand { 25 cmd := &GetTcpInfoCommand{ 26 RavenCommandBase: NewRavenCommandBase(), 27 28 tag: tag, 29 dbName: dbName, 30 } 31 cmd.IsReadRequest = true 32 return cmd 33 } 34 35 func (c *GetTcpInfoCommand) CreateRequest(node *ServerNode) (*http.Request, error) { 36 url := "" 37 if c.dbName == "" { 38 url = node.URL + "/info/tcp?tcp=" + c.tag 39 } else { 40 url = node.URL + "/databases/" + c.dbName + "/info/tcp?tag=" + c.tag 41 } 42 c.requestedNode = node 43 return newHttpGet(url) 44 } 45 46 func (c *GetTcpInfoCommand) SetResponse(response []byte, fromCache bool) error { 47 if len(response) == 0 { 48 return throwInvalidResponse() 49 } 50 51 return jsonUnmarshal(response, &c.Result) 52 }