Documentation
¶
Index ¶
- type IWsTcpSvrEventHandler
- type TcpConnInfo
- type WsTcpSvr
- func (s *WsTcpSvr) Close(conn net.Conn) error
- func (s *WsTcpSvr) InitAndRun(implType, mod string, port int, handler IWsTcpSvrEventHandler) error
- func (s *WsTcpSvr) Quiesce()
- func (s *WsTcpSvr) RunGinWs(mode string, wsPort int) error
- func (s *WsTcpSvr) ServeErrors() <-chan error
- func (s *WsTcpSvr) Stop(_ context.Context) error
- func (s *WsTcpSvr) WriteData(conn net.Conn, data1 []byte, data2 []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IWsTcpSvrEventHandler ¶ added in v1.0.4
type TcpConnInfo ¶ added in v1.0.4
type TcpConnInfo struct {
// contains filtered or unexported fields
}
type WsTcpSvr ¶ added in v1.0.4
type WsTcpSvr struct {
// contains filtered or unexported fields
}
func (*WsTcpSvr) InitAndRun ¶ added in v1.0.4
func (s *WsTcpSvr) InitAndRun(implType, mod string, port int, handler IWsTcpSvrEventHandler) error
func (*WsTcpSvr) Quiesce ¶ added in v1.2.5
func (s *WsTcpSvr) Quiesce()
Quiesce 停止接受新 WS Upgrade,保留既有连接处理在途工作。幂等。
关闭 HTTP listener 以停止新 Upgrade(gin 的 Serve 会退出),但保留已升级的 WebSocket 连接;它们的拆除留给 Stop 强制执行。
func (*WsTcpSvr) RunGinWs ¶ added in v1.0.4
RunGinWs 同步绑定 HTTP 监听器并启动 Gin WebSocket 服务。
关键修复:
- 同步 net.Listen 使端口冲突在 Start 期(而非稍后的 goroutine 内)返回。
- 删除包级全局 gin.Engine,改为实例字段,支持同进程多 WS 实例。
- 保存 listener / http.Server,使 Quiesce 能关闭 listener 停止新 Upgrade、Stop 能 强制 Close 残留连接。
- Serve goroutine 的非预期退出错误送入 serveErr(容量 1),供上层监督(如 RuntimeErrorSource)感知监听器死亡;预期的 http.ErrServerClosed 不上报。
func (*WsTcpSvr) ServeErrors ¶ added in v1.2.5
ServeErrors 返回 ws gin server 的运行期错误 channel(容量 1)。非预期退出(非 http.ErrServerClosed)会送入此 channel,供上层监督监听器死亡。
Click to show internal directories.
Click to hide internal directories.