Documentation
¶
Index ¶
- Constants
- Variables
- func CreateRequest(reqData RequestData, method WsApiMethodType, params map[string]interface{}) ([]byte, error)
- func CreateUnsignedRequest(requestID string, method WsApiMethodType, params map[string]interface{}) ([]byte, error)
- type Client
- type Connection
- type RequestData
- type RequestList
- type WsApiMethodType
- type WsApiRequest
Constants ¶
View Source
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" // SessionLogonSpotWsApiMethod define method to authenticate, or change the API key associated with the connection SessionLogonSpotWsApiMethod = "session.logon" // SessionStatusSpotWsApiMethod define method to check connection status and the current API key SessionStatusSpotWsApiMethod = "session.status" // SessionLogoutSpotWsApiMethod define method to forget the API key associated with the connection SessionLogoutSpotWsApiMethod = "session.logout" // UserDataStreamSubscribeSpotWsApiMethod define method to subscribe to user data stream via websocket API UserDataStreamSubscribeSpotWsApiMethod = "userDataStream.subscribe" // UserDataStreamUnsubscribeSpotWsApiMethod define method to unsubscribe from user data stream via websocket API UserDataStreamUnsubscribeSpotWsApiMethod = "userDataStream.unsubscribe" UserMarginDataStreamSubscribeWsApiMethod = "userDataStream.subscribe.listenToken" )
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 // WaitCheckInternal defines interval for ticker when it checks pending requests while stop application WaitCheckInternal = 300 * time.Millisecond )
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
func CreateUnsignedRequest ¶
func CreateUnsignedRequest(requestID string, method WsApiMethodType, params map[string]interface{}) ([]byte, error)
CreateUnsignedRequest creates unsigned 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)
Close() 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
type WsApiRequest ¶
type WsApiRequest struct {
Id string `json:"id"`
Method WsApiMethodType `json:"method"`
Params map[string]interface{} `json:"params,omitempty"`
}
WsApiRequest define common websocket API request
Click to show internal directories.
Click to hide internal directories.