优化服务退出流程,增加中间件文档

This commit is contained in:
孟帅
2023-05-15 18:37:40 +08:00
parent fdefb42253
commit c511a2e6b3
30 changed files with 335 additions and 97 deletions

View File

@@ -195,7 +195,9 @@ func (client *Client) connect() {
reconnect:
conn := client.dial()
if conn == nil {
client.Logger.Debugf(client.Ctx, "client dial failed")
if !client.stopFlag {
client.Logger.Debugf(client.Ctx, "client dial failed")
}
return
}
@@ -311,6 +313,11 @@ func (client *Client) Stop() {
client.Close()
}
// IsStop 是否已停止
func (client *Client) IsStop() bool {
return client.stopFlag
}
// Destroy 销毁当前连接
func (client *Client) Destroy() {
client.stopCron()

View File

@@ -294,6 +294,11 @@ func (server *Server) Close() {
server.wgLn.Wait()
}
// IsClose 服务是否关闭
func (server *Server) IsClose() bool {
return server.closeFlag
}
// Write 向指定客户端发送消息
func (server *Server) Write(conn *gtcp.Conn, data interface{}) (err error) {
if server.closeFlag {