Repository navigation
feat(opencode): 用量窗口支持同 Key 组共享、活动防抖与超窗强刷 - #6
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
OpenCode Go 是同 API Key 聚合订阅(同一把 key 可挂多个账号),与 Ollama Cloud usage 场景同构。v1(PR #5)只做了单账号周期刷新;本 PR 补齐三项能力,语义对齐 Ollama Cloud usage:
sha256("opencode.ai\0"+api_key);auto_refresh 开关与 snapshot 按组写(事务 + FOR NO KEY UPDATE + 锚点 CAS + 纯合并语义——写 snapshot 不抹开关);列表/详情 ResolveAccounts 组内共享;账号换 Key → IdentityChanged → 组级关闭 auto_refresh 并清快照debounce_minutes(默认 1,1–60,必须小于 interval_minutes,Set 校验;旧值缺省补 1)due = min(lastUsed+debounce, fetchedAt+maxWait),保证刷新不会被连续流量无限推迟;成功路径有 5 分钟最小抓取间隔,失败路径due = max(activityDue, next_refresh_at)(退避优先)其他:活动信号接入与 Ollama 相同的 5 个网关调用点(仅真实上游尝试计入);手动刷新限频 10s→30s 且按组;singleflight/RunDue 按组去重;ListDue 在 SQL 内按组算 due(CTE + 分组排名),到期组不会被活跃组饿死。
变更文件
验证
go build ./...OK;service/handler-admin/repository/dto/cmd 全量回归 OK;gofmt/vet 干净vue-tsc --noEmit零错误已知限制