Skip to content

简化 VM 空闲刷新机制:统一由 control 流触发#459

Merged
yokowu merged 6 commits intomainfrom
feat/vm-idle-refresh-simplify
Apr 7, 2026
Merged

简化 VM 空闲刷新机制:统一由 control 流触发#459
yokowu merged 6 commits intomainfrom
feat/vm-idle-refresh-simplify

Conversation

@yokowu
Copy link
Copy Markdown
Collaborator

@yokowu yokowu commented Apr 7, 2026

Summary

  • 新建 biz/vmidle 模块,将 VM 空闲刷新逻辑从 HostUsecase 解耦为独立的 VMIdleRefresher 接口
  • 统一由 control WebSocket 流触发活动刷新和 VM 恢复,保证来源唯一性
  • 删除分散的旧入口(VMActivity 接口、VmReady 中的 RefreshIdleTimers、attachStream 中的 Resume)
  • 更新默认值:休眠 15 分钟,回收 3 天

核心规则

有 control WebSocket 连接 = 用户活跃

  • 连接建立:刷新空闲计时器 + 如果 VM 休眠则自动恢复
  • 连接存续:每 5 分钟定期刷新(< 15 分钟休眠阈值)
  • 最后连接断开:刷新计时器,开始空闲倒计时

变更

文件 改动
biz/vmidle/ 新建模块:VMIdleRefresher 接口 + 实现 + 三阶段 consumer
biz/task/handler/v1/task_control.go control 流集成 Refresh/Resume/KeepAlive
biz/host/usecase/host.go 移除空闲相关逻辑(-278 行)
biz/host/handler/v1/internal.go 删除 VMActivity 接口和 VmReady RefreshIdleTimers
config/config.go sleep 600→900s, recycle 604800→259200s

🤖 Generated with Claude Code

yokowu and others added 6 commits April 7, 2026 16:13
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yokowu yokowu force-pushed the feat/vm-idle-refresh-simplify branch 2 times, most recently from 12274e1 to 936e6a5 Compare April 7, 2026 11:59
@yokowu yokowu merged commit 39a045f into main Apr 7, 2026
@yokowu yokowu deleted the feat/vm-idle-refresh-simplify branch April 7, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant