Documentation ¶
Overview ¶
Package wsutil provides abstractions around the Websocket, including rate limits.
Index ¶
Constants ¶
View Source
const CopyBufferSize = 2048
View Source
const DefaultTimeout = time.Minute
Variables ¶
View Source
var CloseDeadline = time.Second
CloseDeadline controls the deadline to wait for sending the Close frame.
View Source
var ErrWebsocketClosed = errors.New("Websocket is closed.")
ErrWebsocketClosed is returned if the websocket is already closed.
Functions ¶
func NewDialLimiter ¶
func NewIdentityLimiter ¶
func NewSendLimiter ¶
Types ¶
type Connection ¶
type Connection interface { // Dial dials the address (string). Context needs to be passed in for // timeout. This method should also be re-usable after Close is called. Dial(context.Context, string) error // Listen sends over events constantly. Error will be non-nil if Data is // nil, so check for Error first. Listen() <-chan Event // Send allows the caller to send bytes. Thread safety is a requirement. Send([]byte) error // Close should close the websocket connection. The connection will not be // reused. Close() error }
Connection is an interface that abstracts around a generic Websocket driver. This connection expects the driver to handle compression by itself, including modifying the connection URL.
Click to show internal directories.
Click to hide internal directories.