Documentation ¶
Overview ¶
Package wsutil provides abstractions around the Websocket, including rate limits.
Index ¶
Constants ¶
View Source
const DefaultTimeout = time.Minute
Variables ¶
View Source
var WSBuffer = 12
View Source
var WSReadLimit int64 = 8192000 // 8 MiB
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. Context needs to be passed in order // to re-use the context that's already used for the limiter. Send(context.Context, []byte) error // Close should close the websocket connection. The connection will not be // reused. // If error is nil, the connection should close with a StatusNormalClosure // (1000). If not, it should close with a StatusProtocolError (1002). Close(err error) error }
Connection is an interface that abstracts around a generic Websocket driver. This connection expects the driver to handle compression by itself.
Click to show internal directories.
Click to hide internal directories.