Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ChannelStats ¶
type ChannelStats struct { Last string `json:"last"` //how many seconds ago... Bytes float64 `json:"bytes"` Dt float64 `json:"dt"` //Messages per second }
ChannelStats represents statistics on a particular channel's communications
type Client ¶
type Client struct { Hub *Hub Name string //for filtering who to send messages to Send chan Message // for outbound messages to client Stats *ClientStats Topic string // message broadcast scope is restricted to a single topic Done chan struct{} }
Client is a middleperson between the hub and whatever is sending/receiving messages on it
type ClientReport ¶
type ClientReport struct { Topic string `json:"topic"` Connected string `json:"connected"` Stats ClientRxTx `json:"stats"` }
ClientReport represents statistics that we report externally
type ClientRxTx ¶
type ClientRxTx struct { Tx ChannelStats `json:"tx"` Rx ChannelStats `json:"rx"` }
ClientRxTx represents statistics on a particular client's communications
type ClientStats ¶
ClientStats represents statistics that we keep internally
func NewClientStats ¶
func NewClientStats() *ClientStats
NewClientStats returns a pointer to a new initialised ClientStats
type Hub ¶
type Hub struct { // Registered clients. Clients map[string]map[*Client]bool // Inbound messages from the clients. Broadcast chan Message // Register requests from the clients. Register chan *Client // Unregister requests from clients. Unregister chan *Client Stats Stats }
Hub maintains the set of active clients and broadcasts messages to the clients. From gorilla/websocket chat
func (*Hub) RunWithStats ¶
func (h *Hub) RunWithStats(closed chan struct{})
RunWithStats starts the hub, and records statistics
type Message ¶
type Message struct { Data []byte //text data are converted to/from bytes as needed Sender Client Sent time.Time //when sent Type int }
Message represents a message that is wrapped and ready for multiplexing unwrapped messages cannot be multiplexed
type Report ¶
type Report struct { Started string `json:"started"` Last string `json:"last"` Audience WelfordStats `json:"audience"` Bytes WelfordStats `json:"bytes"` Latency WelfordStats `json:"latency"` Dt WelfordStats `json:"dt"` }
Report represents statistics that we report externally