Versions in this module Expand all Collapse all v0 v0.1.0 Feb 15, 2026 Changes in this version + var ErrConnectionClosed = errors.New("wsreconnect: client is closed") + var ErrMaxRetriesExceeded = errors.New("wsreconnect: maximum reconnection retries exceeded") + var ErrNotConnected = errors.New("wsreconnect: client is not connected") + var ErrWriteBufferFull = errors.New("wsreconnect: outbound write buffer is full") + type BackoffConfig struct + InitialInterval time.Duration + Jitter bool + MaxInterval time.Duration + MaxRetries int + Multiplier float64 + func DefaultBackoffConfig() BackoffConfig + type Client struct + func New(rawURL string, opts ...Option) *Client + func (c *Client) Close() error + func (c *Client) Connect(ctx context.Context) error + func (c *Client) IsClosed() bool + func (c *Client) IsConnected() bool + func (c *Client) ReconnectCount() int64 + func (c *Client) SendBinary(data []byte) error + func (c *Client) SendJSON(v any) error + func (c *Client) SendText(text string) error + type Config struct + Backoff BackoffConfig + Headers http.Header + OnBinaryMessage func(msg []byte) + OnConnect func() + OnDisconnect func(err error) + OnError func(err error) + OnTextMessage func(msg []byte) + PingInterval time.Duration + PongWait time.Duration + ReadBufferSize int + Subprotocols []string + WriteBufferSize int + WriteChanSize int + WriteWait time.Duration + func DefaultConfig() Config + type Option func(*Config) + func WithBackoff(cfg BackoffConfig) Option + func WithBufferSize(readSize, writeSize int) Option + func WithHeaders(headers http.Header) Option + func WithOnBinaryMessage(fn func(msg []byte)) Option + func WithOnConnect(fn func()) Option + func WithOnDisconnect(fn func(err error)) Option + func WithOnError(fn func(err error)) Option + func WithOnTextMessage(fn func(msg []byte)) Option + func WithPingInterval(d time.Duration) Option + func WithPongWait(d time.Duration) Option + func WithSubprotocols(subprotocols ...string) Option + func WithWriteChanSize(size int) Option + func WithWriteWait(d time.Duration) Option