config增加心跳时间

This commit is contained in:
2025-09-09 13:35:22 +08:00
parent d90698401d
commit 3cc02d3a98
2 changed files with 8 additions and 6 deletions

View File

@@ -26,6 +26,8 @@ database:
websocket:
# WebSocket请求超时时间(秒)
timeout: 5
# 心跳检测间隔(秒), 如果超过这个时间没有消息往来系统会自动发送一个心跳包维持长链接
heartbeat_interval: 54
# 心跳配置
heartbeat:

View File

@@ -77,6 +77,9 @@ type DatabaseConfig struct {
type WebSocketConfig struct {
// Timeout WebSocket请求超时时间(秒)
Timeout int `yaml:"timeout"`
// HeartbeatInterval 心跳检测间隔(秒), 如果超过这个时间没有消息往来系统会自动发送一个心跳包维持长链接
HeartbeatInterval int `yaml:"heartbeat_interval"`
}
// HeartbeatConfig 代表心跳配置
@@ -130,12 +133,9 @@ func (c *Config) GetDatabaseConnectionString() string {
)
}
// GetWebSocketTimeout 获取WebSocket超时时间(秒)
func (c *Config) GetWebSocketTimeout() int {
if c.WebSocket.Timeout <= 0 {
return 5 // 默认5秒超时
}
return c.WebSocket.Timeout
// GetWebSocketConfig 获取WebSocket配置
func (c *Config) GetWebSocketConfig() WebSocketConfig {
return c.WebSocket
}
// GetHeartbeatConfig 获取心跳配置