Documentation ¶
Index ¶
- Constants
- func IsSocketFile(path string) bool
- func NewClient() *resty.Client
- func NewSocketListener(path string) (*net.UnixListener, error)
- func NewTcpListener(addr string) (*net.TCPListener, error)
- func SendDeleteRequest(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) error
- func SendDeleteRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) (*resty.Response, error)
- func SendDeleteRequestViaUnixSocket(socketPath string, uri string, param, ret interface{}) error
- func SendGetRequest(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) error
- func SendGetRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) (*resty.Response, error)
- func SendGetRequestViaUnixSocket(socketPath string, uri string, param, ret interface{}) error
- func SendPatchRequest(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) error
- func SendPatchRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) (*resty.Response, error)
- func SendPatchRequestViaUnixSocket(socketPath string, uri string, param, ret interface{}) error
- func SendPostRequest(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) error
- func SendPostRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) (*resty.Response, error)
- func SendPostRequestViaUnixSocket(socketPath string, uri string, param, ret interface{}) error
- func SendPutRequest(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) error
- func SendPutRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) (*resty.Response, error)
- func SendPutRequestViaUnixSocket(socketPath string, uri string, param, ret interface{}) error
- func SendRequestAndBuildReturn(agentInfo meta.AgentInfoInterface, uri string, method string, ...) error
- func SendRequestAndBuildReturnViaUnixSocket(socketPath, uri, method string, param, ret interface{}, ...) error
- func SendRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, method string, ...) (*resty.Response, error)
- func SendRequestAndReturnResponseViaUnixSocket(socketPath string, uri string, method string, param, ret interface{}, ...) (*resty.Response, error)
- func SocketCanConnect(network, addr string, timeout time.Duration) bool
- func SocketIsActive(socketPath string) bool
- func UploadFileViaUnixSocket(socketPath, uri, filePath string, ret interface{}) (err error)
- type AgentStatus
- type ApiError
- type ApiFieldError
- type ApiUnknownError
- type IterableData
- type Listener
- type OcsAgentResponse
- type OcsAgentResponseData
- type State
Constants ¶
const ( GET = "GET" // http get method PUT = "PUT" // http put method POST = "POST" // http post method PATCH = "PATCH" // http patch method DELETE = "DELETE" // http delete method TCP_DEFAULT_TIME_OUT = 3 * time.Minute // default timeout )
const UNIX_SOCKET_DEFAULT_TIME_OUT = 30 * time.Second
Variables ¶
This section is empty.
Functions ¶
func IsSocketFile ¶
func NewSocketListener ¶
func NewSocketListener(path string) (*net.UnixListener, error)
func NewTcpListener ¶
func NewTcpListener(addr string) (*net.TCPListener, error)
func SendDeleteRequest ¶
func SendDeleteRequest(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) error
SendDeleteRequest will send http delete request to the agent. If ret is not nil, it should be a pointer.
func SendDeleteRequestAndReturnResponse ¶
func SendDeleteRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) (*resty.Response, error)
SendDeleteRequestAndReturnResponse will return http response and error. If ret is not nil, it should be a pointer.
func SendGetRequest ¶
func SendGetRequest(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) error
SendGetRequest will send http get request to the agent. If ret is not nil, it should be a pointer.
func SendGetRequestAndReturnResponse ¶
func SendGetRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) (*resty.Response, error)
SendGetRequestAndReturnResponse will return http response and error. If ret is not nil, it should be a pointer.
func SendPatchRequest ¶
func SendPatchRequest(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) error
SendPatchRequest will send http patch request to the agent. If ret is not nil, it should be a pointer.
func SendPatchRequestAndReturnResponse ¶
func SendPatchRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) (*resty.Response, error)
SendPatchRequestAndReturnResponse will return http response and error. If ret is not nil, it should be a pointer.
func SendPostRequest ¶
func SendPostRequest(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) error
SendPostRequest will send http post request to the agent. If ret is not nil, it should be a pointer.
func SendPostRequestAndReturnResponse ¶
func SendPostRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) (*resty.Response, error)
SendPostRequestAndReturnResponse will return http response and error. If ret is not nil, it should be a pointer.
func SendPutRequest ¶
func SendPutRequest(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) error
SendPutRequest will send http put request to the agent. If ret is not nil, it should be a pointer.
func SendPutRequestAndReturnResponse ¶
func SendPutRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, param, ret interface{}) (*resty.Response, error)
SendPutRequestAndReturnResponse will return http response and error. If ret is not nil, it should be a pointer.
func SendRequestAndReturnResponse ¶
func SendRequestAndReturnResponse(agentInfo meta.AgentInfoInterface, uri string, method string, param, ret interface{}, headers map[string]string) (*resty.Response, error)
SendRequestAndReturnResponse will return http response and error.
func SocketIsActive ¶
func UploadFileViaUnixSocket ¶
Types ¶
type AgentStatus ¶
type AgentStatus struct { Agent meta.AgentInfoWithIdentity `json:"agent"` State int32 `json:"state"` // service state Version string `json:"version"` // service version Pid int `json:"pid"` // service pid StartAt int64 `json:"startAt"` // timestamp when service started Port int `json:"port"` // Ports process occupied ports OBState int `json:"obState"` UnderMaintenance bool `json:"underMaintenance"` }
Status info api response
type ApiError ¶
type ApiError struct { Code int `json:"code"` // Error code Message string `json:"message"` // Error message SubErrors []interface{} `json:"subErrors,omitempty"` // Sub errors }
ApiError is the api error struct of ocsagent.
type ApiFieldError ¶
type ApiFieldError struct { Tag string `json:"tag"` Field string `json:"field"` Message string `json:"message"` }
ApiFieldError is the api field error struct of ocsagent.
type ApiUnknownError ¶
type ApiUnknownError struct {
Error error `json:"error"`
}
type IterableData ¶
type IterableData struct {
Contents interface{} `json:"contents"`
}
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
func NewListener ¶
func NewListener() *Listener
type OcsAgentResponse ¶
type OcsAgentResponse struct { Successful bool `json:"successful"` // Whether request successful or not Timestamp time.Time `json:"timestamp"` // Request handling timestamp (server time) Duration int64 `json:"duration"` // Request handling time cost (ms) Status int `json:"status"` // HTTP status code TraceId string `json:"traceId"` // Request trace ID, contained in server logs Data interface{} `json:"data,omitempty"` // Data payload when response is successful Error *ApiError `json:"error,omitempty"` // Error payload when response is failed }
OcsAgentResponse is the response struct of ocsagent.
func BuildNoContentResponse ¶
func BuildNoContentResponse() OcsAgentResponse
func BuildResponse ¶
func BuildResponse(data interface{}, err error) OcsAgentResponse
func NewSubErrorsResponse ¶
func NewSubErrorsResponse(subErrors []interface{}) OcsAgentResponse
type OcsAgentResponseData ¶
type OcsAgentResponseData struct {
TaskId int
}
OcsAgentResponseData is the response data struct of ocsagent.
type State ¶
type State struct {
// contains filtered or unexported fields
}