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 ¶
type ConnectedEvent struct {
URL string
}
ConnectedEvent is emitted when the WebSocket connection is established.
func (*ConnectedEvent) String ¶
func (e *ConnectedEvent) String() string
type ConnectingEvent ¶
type ConnectingEvent struct {
URL string
}
ConnectingEvent is emitted when a new connection is being established.
func (*ConnectingEvent) String ¶
func (e *ConnectingEvent) String() string
type DisconnectedEvent ¶
DisconnectedEvent is emitted when the WebSocket connection is lost.
func (*DisconnectedEvent) String ¶
func (e *DisconnectedEvent) String() string
type ObjectStream ¶
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 ¶
func NewObjectStream(conn *websocket.Conn, writeTimeout, readTimeout time.Duration) *ObjectStream
func (*ObjectStream) Close ¶
func (stream *ObjectStream) Close() error
func (*ObjectStream) ReadObject ¶
func (stream *ObjectStream) ReadObject(v interface{}) error
func (*ObjectStream) WriteObject ¶
func (stream *ObjectStream) WriteObject(v interface{}) error
type Option ¶
type Option func(*Transport)
Option represents an option that can be passed into the transport constructor.
func SetAutoReconnectEnabled ¶
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 ¶
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 ¶
SetDialTimeout can be used to set the timeout when establishing a new connection.
This function is deprecated, please use SetHandshakeTimeout.
func SetHandshakeTimeout ¶
SetHandshakeTimeout can be used to set the timeout for WebSocket handshake.
func SetMonitor ¶
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 ¶
SetReadTimeout sets the connection read timeout. The timeout is implemented using net.Conn.SetReadDeadline.
func SetReadWriteTimeout ¶
SetReadWriteTimeout sets the connection read and write timeout. The timeout is implemented using net.Conn.SetDeadline.
func SetWriteTimeout ¶
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 Hive RPC endpoint over WebSocket.
func NewTransport ¶
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.