Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrorWsReadConnectionTimeout defines that connection read timeout expired ErrorWsReadConnectionTimeout = errors.New("ws error: read connection timeout") // ErrorWsIdAlreadySent defines that request with the same id was already sent ErrorWsIdAlreadySent = errors.New("ws error: request with same id already sent") // KeepAlivePingDeadline defines deadline to send ping frame KeepAlivePingDeadline = 10 * time.Second )
View Source
var ( // ErrorRequestIDNotSet defines that request ID is not set ErrorRequestIDNotSet = errors.New("ws service: request id is not set") // ErrorApiKeyIsNotSet defines that ApiKey is not set ErrorApiKeyIsNotSet = errors.New("ws service: api key is not set") // ErrorSecretKeyIsNotSet defines that SecretKey is not set ErrorSecretKeyIsNotSet = errors.New("ws service: secret key is not set") )
View Source
var ( // WriteSyncWsTimeout defines timeout for WriteSync method of client_ws WriteSyncWsTimeout = 5 * time.Second )
Functions ¶
func CreateRequest ¶
func CreateRequest(reqData RequestData, method WsApiMethodType, params map[string]interface{}) ([]byte, error)
CreateRequest creates signed ws request
Types ¶
type Client ¶
type Connection ¶
type Connection interface { WriteMessage(messageType int, data []byte) error ReadMessage() (messageType int, p []byte, err error) RestoreConnection() (Connection, error) }
func NewConnection ¶
func NewConnection( initUnderlyingWsConnFn func() (*websocket.Conn, error), isKeepAliveNeeded bool, keepaliveTimeout time.Duration, ) (Connection, error)
NewConnection constructor for connection
type RequestData ¶
type RequestData struct {
// contains filtered or unexported fields
}
func NewRequestData ¶
type RequestList ¶
type RequestList struct {
// contains filtered or unexported fields
}
RequestList state of requests that was sent/received
func (*RequestList) IsAlreadyInList ¶
func (l *RequestList) IsAlreadyInList(id string) bool
IsAlreadyInList checks if id is presented in requests list
func (*RequestList) RecreateList ¶
func (l *RequestList) RecreateList()
RecreateList creates new request list
type WsApiMethodType ¶
type WsApiMethodType string
WsApiMethodType define method name for websocket API
const ( // OrderPlaceSpotWsApiMethod define method for creation order via websocket API OrderPlaceSpotWsApiMethod WsApiMethodType = "order.place" // OrderPlaceFuturesWsApiMethod define method for creation order via websocket API OrderPlaceFuturesWsApiMethod WsApiMethodType = "order.place" // CancelFuturesWsApiMethod define method for cancel order via websocket API CancelFuturesWsApiMethod WsApiMethodType = "order.cancel" )
type WsApiRequest ¶
type WsApiRequest struct { Id string `json:"id"` Method WsApiMethodType `json:"method"` Params map[string]interface{} `json:"params"` }
WsApiRequest define common websocket API request
Click to show internal directories.
Click to hide internal directories.