Documentation ¶
Overview ¶
Package wsdcrdata provides a client for managing dcrdata websocket subscriptions.
Index ¶
- Variables
- func DisableLog()
- func UseLogger(logger slog.Logger)
- type Client
- func (c *Client) AddressSubscribe(address string) error
- func (c *Client) AddressUnsubscribe(address string) error
- func (c *Client) Close() error
- func (c *Client) NewBlockSubscribe() error
- func (c *Client) NewBlockUnsubscribe() error
- func (c *Client) Receive() <-chan *psclient.ClientMessage
- func (c *Client) Reconnect()
- func (c *Client) Status() StatusT
- type StatusT
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDuplicateSub is emitted when attempting to subscribe to an // event that has already been subscribed to. ErrDuplicateSub = errors.New("duplicate subscription") // ErrSubNotFound is emitted when attempting to unsubscribe to an // event that has not yet been subscribed to. ErrSubNotFound = errors.New("subscription not found") // ErrReconnecting is emitted when attempting to use the Client // while it is in the process of reconnecting to dcrdata. All // subscribe/unsubscribe actions that are attempted while the // client is reconnecting are recorded and completed once the new // connection has been made. ErrReconnecting = errors.New("reconnecting to dcrdata") // ErrShutdown is emitted when attempting to use the Client after // it has already been shut down. ErrShutdown = errors.New("client is shutdown") )
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
Types ¶
type Client ¶
Client is a dcrdata websocket client for managing dcrdata websocket subscriptions.
func (*Client) AddressSubscribe ¶
AddressSubscribe subscribes to events for the provided address.
func (*Client) AddressUnsubscribe ¶
AddressUnsubscribe unsubscribes from events for the provided address.
func (*Client) NewBlockSubscribe ¶
NewBlockSubscribe subscibes to the new block event.
func (*Client) NewBlockUnsubscribe ¶
NewBlockUnsubscribe unsubscibes from the new block event.
func (*Client) Receive ¶
func (c *Client) Receive() <-chan *psclient.ClientMessage
Receive returns a new channel that receives websocket messages from the dcrdata server.
func (*Client) Reconnect ¶
func (c *Client) Reconnect()
Reconnect creates a new websocket client and subscribes to the same subscriptions as the previous client. If a connection cannot be established, this function will continue to episodically attempt to reconnect until either a connection is made or the application is shut down. If any new subscribe/unsubscribe events are registered during this reconnection process, they are added to a pending events list and are replayed in the order in which they are received once a new connection has been established.