Documentation
¶
Index ¶
- Constants
- Variables
- type Conn
- type Hub
- func (h *Hub) Broadcast(msg []byte)
- func (h *Hub) BroadcastContext(ctx context.Context, msg []byte) error
- func (h *Hub) Close() error
- func (h *Hub) Len() int
- func (h *Hub) Run()
- func (h *Hub) SetAllowedOrigins(origins []string)
- func (h *Hub) Upgrade(w http.ResponseWriter, r *http.Request) (*Conn, error)
- func (h *Hub) UseRedis(client *redis.Client, topic string) error
- type HubOptions
Constants ¶
View Source
const DefaultRedisTopic = "nimbus:websocket:broadcast"
Variables ¶
View Source
var ErrBackpressure = errors.New("websocket: broadcast queue full")
View Source
var ErrClosed = errors.New("websocket: hub closed")
View Source
var ErrMessageTooLarge = errors.New("websocket: message exceeds configured limit")
Functions ¶
This section is empty.
Types ¶
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
func NewHubWithOptions ¶ added in v1.15.2
func NewHubWithOptions(o HubOptions) *Hub
func (*Hub) Broadcast ¶
Broadcast retains the original convenience API. Use BroadcastContext when the caller needs to handle cancellation, oversize or saturation errors explicitly.
func (*Hub) BroadcastContext ¶ added in v1.15.2
func (*Hub) Close ¶ added in v1.9.1
Close stops admission, closes clients/subscription and waits for owned pumps. It is idempotent and also works when Run was never called.
func (*Hub) Run ¶
func (h *Hub) Run()
Run delivers broadcasts until Close. Calling it more than once shares one loop.
func (*Hub) SetAllowedOrigins ¶
type HubOptions ¶ added in v1.15.2
type HubOptions struct {
MaxMessageBytes int64 // default 64 KiB (inbound and broadcasts)
MaxConnections int // default 1024, including pending upgrades
SendBuffer int // default 32 messages per client
WriteTimeout time.Duration // default 10s
PongTimeout time.Duration // default 60s
PingInterval time.Duration // default 25s, always below PongTimeout
PublishTimeout time.Duration // default 5s
}
HubOptions bounds per-connection and hub resources. Nonpositive values use safe defaults. Configure before serving; options are immutable after creation.
Click to show internal directories.
Click to hide internal directories.