Documentation
¶
Overview ¶
Wraps a server-side websocket connection with its own human-readable unique ID. This helps to clearly map log debug and error messages to their respective websocket connections, thus keeping them clearly separated. Additionally, we also associate the capturing process (if any) with this connection, so we can sanely manage it.
Index ¶
Constants ¶
const ClosingDeadline = 5 * time.Second
ClosingDeadline specifies the maximum amount of time to wait for a full (opt. graceful) closing procedure to take.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WSConn ¶
type WSConn struct { *websocket.Conn // usual (gorilla) websocket connection. ID string // unique ID string for this connection. // contains filtered or unexported fields }
WSConn is a websocket connection with a unique, human-friendly ID. This allows differentiating multiple (concurrent) websocket connections in the logs.
func NewWSConn ¶
NewWSConn returns a new websocket connection wrapper that features an additional ID, so multiple (concurrent) websocket connections can still be differentiated in the logs.
func (*WSConn) GracefullyClose ¶
GracefullyClose runs a complete graceful close handshake and only returns after this has completed or completely failed. Use this convenience method when there is yet no process to also wait for or to terminate. Otherwise, use asynchronous InitiateGracefulClose because there's already a Watch() on this websocket as well as a Wait() on the capture process running in parallel.
func (*WSConn) InitiateGracefulClose ¶
InitiateGracefulClose initiates a graceful close handshake. It immediately returns after kicking off the close procedure. This will then cause the websocket reader to finish the closing handshake and finally terminating the capture process. If there is a problem to initiate the closing procedure, then the websocket will be closed immediately and the capture process terminated.
type WSConnState ¶
type WSConnState int
WSConnState ...
const ( // WSConnOpen declares the websocket connection being still open. WSConnOpen WSConnState = iota // WSConnClosing declares the websocket connection being in the handshake // for a graceful close. WSConnClosing // WSConnClosed declares the websocket connection being closed. WSConnClosed )