Skip to content

feat: manage kv storage - #11

Merged
YangZxi merged 2 commits into
mainfrom
dev
May 26, 2026
Merged

YangZxi merged 2 commits into
mainfrom
dev

Conversation

@YangZxi

@YangZxi YangZxi commented May 25, 2026

Copy link
Copy Markdown
Owner

No description provided.

Repository owner deleted a comment from chatgpt-codex-connector Bot May 25, 2026
@YangZxi

YangZxi commented May 25, 2026

Copy link
Copy Markdown
Owner Author

@codex
review this

@YangZxi YangZxi self-assigned this May 25, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 919a157a2e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pages/src/pages/StorageKVPage.tsx Outdated
} finally {
setLoading(false);
}
}, [keyword]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 避免关键字变更时触发全量 KV 刷新

loadKeys 依赖了 keyword,而 reloadAll 又依赖 loadKeys 并在 useEffect 中自动执行,这会导致用户每输入一个字符都重新请求一次 /kv/metrics/kv/keys(不仅是点击“搜索”时)。在 key 数量较多或 Redis 较慢时,这会明显放大请求量并拖慢页面交互,属于可见的性能回归;建议让 loadKeys 不依赖输入态(显式传参)或将初始化加载与搜索行为拆开。

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex fix

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

  • 已修复 StorageKVPageloadKeys 对输入态 keyword 的隐式依赖:loadKeys 现在默认使用空字符串且依赖数组为 [],避免用户每次输入都间接触发 reloadAll 及全量请求。. pages/src/pages/StorageKVPage.tsxL92-L103
  • 已将 reloadAll 改为显式调用 loadKeys(""),把“全量刷新”行为限定在初始化、手动刷新、删除后刷新等明确场景,避免输入时的性能回归。. pages/src/pages/StorageKVPage.tsxL117-L123
  • 已保留搜索行为:点击搜索/回车时仍通过 submitSearch -> loadKeys(keyword) 发起按关键字查询,不影响原有交互。. pages/src/pages/StorageKVPage.tsxL125-L127

Testing

  • go test ./...(仓库当前存在与本次改动无关的既有失败:internal/dbinternal/model 测试未通过)。
  • git commit -m "fix: 避免 KV 页面输入时触发全量刷新"(已完成提交,commit: a4c06a7)。

另外,我已按要求调用 make_pr 记录本次后续 PR 标题与说明。

View task →

Comment thread internal/admin/storage/kv_service.go Outdated
return "", "", fmt.Errorf("key 不属于 Callit KV")
}
rest := strings.TrimPrefix(key, redisKeyPrefix)
parts := strings.SplitN(rest, ":", 2)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge 解析 KV key 时保留完整 namespace

这里用 SplitN(rest, ":", 2) 只按第一个冒号切分 namespace/name,但 SDK 对 namespace 仅做了 trim(未禁止 :),因此像 callit:kv:team:prod:session 这样的合法 key 会被解析成 namespace=team、name=prod:session。这会让管理页分组与详情展示出现错误命名空间,影响排查与运维判断;应明确限制 namespace 字符集或采用可逆编码来构造/解析 key。

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex fix

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

  • 已修复 parseKVRedisKey 的切分逻辑:从“按第一个冒号切分”改为“按最后一个冒号切分”,从而正确保留包含冒号的完整 namespace(如 team:prod),避免管理页错误分组。. internal/admin/storage/kv_service.goL74-L90
  • 保留并强化了 key 格式校验:当分隔位置非法或 namespace/name 为空时,仍返回格式错误,避免脏数据进入后续流程。. internal/admin/storage/kv_service.goL80-L88
  • 新增单元测试覆盖:

Testing

  • gofmt -w internal/admin/storage/kv_service.go internal/admin/storage/kv_service_test.go
  • go test ./...(失败为仓库现有用例:internal/dbTestLatestPerWorkerUsesLatestInsertedLoginternal/modelTestWorkerLogIsSuccess,与本次 KV 解析改动无直接关联)

View task →

@YangZxi
YangZxi requested review from Copilot and removed request for Copilot May 25, 2026 15:29
@YangZxi YangZxi added the enhancement New feature or request label May 26, 2026
@YangZxi
YangZxi merged commit f3dd73b into main May 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant