Documentation ¶
Index ¶
- Constants
- type Channel
- type Depth
- type Dispatcher
- type EndpointCreator
- type Parser
- type Speed
- type StandardStream
- func (s *StandardStream) Close() error
- func (s *StandardStream) Connect(ctx context.Context) error
- func (s *StandardStream) Dial(ctx context.Context, args ...string) (*websocket.Conn, error)
- func (s *StandardStream) DialAndConnect(ctx context.Context) error
- func (s *StandardStream) EmitConnect()
- func (s *StandardStream) EmitDisconnect()
- func (s *StandardStream) EmitStart()
- func (s *StandardStream) GetPublicOnly() bool
- func (s *StandardStream) GetSubscriptions() []Subscription
- func (s *StandardStream) OnConnect(cb func())
- func (s *StandardStream) OnDisconnect(cb func())
- func (s *StandardStream) OnStart(cb func())
- func (s *StandardStream) Read(ctx context.Context, conn *websocket.Conn, cancel context.CancelFunc)
- func (s *StandardStream) Reconnect()
- func (s *StandardStream) SetConn(ctx context.Context, conn *websocket.Conn) (context.Context, context.CancelFunc)
- func (s *StandardStream) SetDispatcher(dispatcher Dispatcher)
- func (s *StandardStream) SetEndpointCreator(creator EndpointCreator)
- func (s *StandardStream) SetParser(parser Parser)
- func (s *StandardStream) SetPublicOnly()
- func (s *StandardStream) Subscribe(channel Channel, symbol string, options SubscribeOptions)
- type StandardStreamEmitter
- type StandardStreamEventHub
- type Stream
- type SubscribeOptions
- type Subscription
Constants ¶
View Source
const ( BookChannel = Channel("book") KLineChannel = Channel("kline") BookTickerChannel = Channel("bookTicker") MarketTradeChannel = Channel("trade") AggTradeChannel = Channel("aggTrade") // channels for futures MarkPriceChannel = Channel("markPrice") LiquidationOrderChannel = Channel("liquidationOrder") // ContractInfoChannel is the contract info provided by the exchange ContractInfoChannel = Channel("contractInfo") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher func(e interface{})
type StandardStream ¶
type StandardStream struct { // Conn is the websocket connection Conn *websocket.Conn // ConnCtx is the context of the current websocket connection ConnCtx context.Context // ConnCancel is the cancel funcion of the current websocket connection ConnCancel context.CancelFunc // ConnLock is used for locking Conn, ConnCtx and ConnCancel fields. // When changing these field values, be sure to call ConnLock ConnLock sync.Mutex PublicOnly bool // ReconnectC is a signal channel for reconnecting ReconnectC chan struct{} // CloseC is a signal channel for closing stream CloseC chan struct{} Subscriptions []Subscription // contains filtered or unexported fields }
func NewStandardStream ¶
func NewStandardStream() StandardStream
func (*StandardStream) Close ¶
func (s *StandardStream) Close() error
func (*StandardStream) Connect ¶
func (s *StandardStream) Connect(ctx context.Context) error
Connect starts the stream and create the websocket connection
func (*StandardStream) DialAndConnect ¶
func (s *StandardStream) DialAndConnect(ctx context.Context) error
func (*StandardStream) EmitConnect ¶
func (s *StandardStream) EmitConnect()
func (*StandardStream) EmitDisconnect ¶
func (s *StandardStream) EmitDisconnect()
func (*StandardStream) EmitStart ¶
func (s *StandardStream) EmitStart()
func (*StandardStream) GetPublicOnly ¶
func (s *StandardStream) GetPublicOnly() bool
func (*StandardStream) GetSubscriptions ¶
func (s *StandardStream) GetSubscriptions() []Subscription
func (*StandardStream) OnConnect ¶
func (s *StandardStream) OnConnect(cb func())
func (*StandardStream) OnDisconnect ¶
func (s *StandardStream) OnDisconnect(cb func())
func (*StandardStream) OnStart ¶
func (s *StandardStream) OnStart(cb func())
func (*StandardStream) Read ¶
func (s *StandardStream) Read(ctx context.Context, conn *websocket.Conn, cancel context.CancelFunc)
func (*StandardStream) Reconnect ¶
func (s *StandardStream) Reconnect()
func (*StandardStream) SetConn ¶
func (s *StandardStream) SetConn(ctx context.Context, conn *websocket.Conn) (context.Context, context.CancelFunc)
func (*StandardStream) SetDispatcher ¶
func (s *StandardStream) SetDispatcher(dispatcher Dispatcher)
func (*StandardStream) SetEndpointCreator ¶
func (s *StandardStream) SetEndpointCreator(creator EndpointCreator)
func (*StandardStream) SetParser ¶
func (s *StandardStream) SetParser(parser Parser)
func (*StandardStream) SetPublicOnly ¶
func (s *StandardStream) SetPublicOnly()
func (*StandardStream) Subscribe ¶
func (s *StandardStream) Subscribe(channel Channel, symbol string, options SubscribeOptions)
type StandardStreamEmitter ¶
type StandardStreamEmitter interface { Stream EmitStart() EmitConnect() EmitDisconnect() }
type StandardStreamEventHub ¶
type StandardStreamEventHub interface { OnStart(cb func()) OnConnect(cb func()) OnDisconnect(cb func()) OnTradeUpdate(cb func()) }
type Stream ¶
type Stream interface { StandardStreamEventHub Subscribe(channel Channel, symbol string, options SubscribeOptions) GetSubscriptions() []Subscription SetPublicOnly() GetPublicOnly() bool Connect(ctx context.Context) error Close() error }
type SubscribeOptions ¶
type SubscribeOptions struct { Depth Depth `json:"depth,omitempty"` Speed Speed `json:"speed,omitempty"` }
SubscribeOptions provides the standard stream options
func (SubscribeOptions) String ¶
func (o SubscribeOptions) String() string
type Subscription ¶
type Subscription struct { Symbol string `json:"symbol"` Channel Channel `json:"channel"` Options SubscribeOptions `json:"options"` }
Click to show internal directories.
Click to hide internal directories.