Documentation ¶
Index ¶
- Constants
- Variables
- type ConnectedEvent
- type ConnectingEvent
- type DisconnectedEvent
- type ObjectStream
- type Option
- func SetAutoReconnectEnabled(enabled bool) Option
- func SetAutoReconnectMaxDelay(delay time.Duration) Option
- func SetDialTimeout(timeout time.Duration) Option
- func SetHandshakeTimeout(timeout time.Duration) Option
- func SetMonitor(monitorChan chan<- interface{}) Option
- func SetReadTimeout(timeout time.Duration) Option
- func SetReadWriteTimeout(timeout time.Duration) Option
- func SetWriteTimeout(timeout time.Duration) Option
- type Transport
Constants ¶
Variables ¶
var ErrClosing = errors.New("closing")
Functions ¶
This section is empty.
Types ¶
type ConnectedEvent ¶ added in v0.2.0
type ConnectedEvent struct {
URL string
}
ConnectedEvent is emitted when the WebSocket connection is established.
func (*ConnectedEvent) String ¶ added in v0.2.0
func (e *ConnectedEvent) String() string
type ConnectingEvent ¶ added in v0.2.0
type ConnectingEvent struct {
URL string
}
ConnectingEvent is emitted when a new connection is being established.
func (*ConnectingEvent) String ¶ added in v0.2.0
func (e *ConnectingEvent) String() string
type DisconnectedEvent ¶ added in v0.2.0
DisconnectedEvent is emitted when the WebSocket connection is lost.
func (*DisconnectedEvent) String ¶ added in v0.2.0
func (e *DisconnectedEvent) String() string
type ObjectStream ¶ added in v0.9.0
type ObjectStream struct {
// contains filtered or unexported fields
}
ObjectStream implements jsonrpc2.ObjectStream that uses a WebSocket. It extends jsonrpc2/websocket.ObjectStream with read/write timeouts.
func NewObjectStream ¶ added in v0.9.0
func NewObjectStream(conn *websocket.Conn, writeTimeout, readTimeout time.Duration) *ObjectStream
func (*ObjectStream) Close ¶ added in v0.9.0
func (stream *ObjectStream) Close() error
func (*ObjectStream) ReadObject ¶ added in v0.9.0
func (stream *ObjectStream) ReadObject(v interface{}) error
func (*ObjectStream) WriteObject ¶ added in v0.9.0
func (stream *ObjectStream) WriteObject(v interface{}) error
type Option ¶ added in v0.2.0
type Option func(*Transport)
Option represents an option that can be passed into the transport constructor.
func SetAutoReconnectEnabled ¶ added in v0.2.0
SetAutoReconnectEnabled can be used to enable automatic reconnection to the RPC endpoint. Exponential backoff is used when the connection cannot be established repetitively.
See SetAutoReconnectMaxDelay to set the maximum delay between the reconnection attempts.
func SetAutoReconnectMaxDelay ¶ added in v0.2.0
SetAutoReconnectMaxDelay can be used to set the maximum delay between the reconnection attempts.
This option only takes effect when the auto-reconnect mode is enabled.
The default value is 5 minutes.
func SetDialTimeout ¶ added in v0.2.0
SetDialTimeout can be used to set the timeout when establishing a new connection.
This function is deprecated, please use SetHandshakeTimeout.
func SetHandshakeTimeout ¶ added in v0.9.0
SetHandshakeTimeout can be used to set the timeout for WebSocket handshake.
func SetMonitor ¶ added in v0.2.0
func SetMonitor(monitorChan chan<- interface{}) Option
SetMonitor can be used to set the monitoring channel that can be used to watch connection-related state changes.
All channel send operations are happening synchronously, so not receiving messages from the channel will lead to the whole thing getting stuck completely.
This option only takes effect when the auto-reconnect mode is enabled.
The channel is closed when the transport is closed.
func SetReadTimeout ¶ added in v0.2.0
SetReadTimeout sets the connection read timeout. The timeout is implemented using net.Conn.SetReadDeadline.
func SetReadWriteTimeout ¶ added in v0.2.0
SetReadWriteTimeout sets the connection read and write timeout. The timeout is implemented using net.Conn.SetDeadline.
func SetWriteTimeout ¶ added in v0.2.0
SetWriteTimeout sets the connection read timeout. The timeout is implemented using net.Conn.SetWriteDeadline.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport implements a CallCloser accessing the Steem RPC endpoint over WebSocket.
func NewTransport ¶ added in v0.2.0
NewTransport creates a new transport that connects to the given WebSocket URLs.
It is possible to specify multiple WebSocket endpoint URLs. In case the transport is configured to reconnect automatically, the URL to connect to is rotated on every connect attempt using round-robin.