Skip to content

Conversation

@HynoR
Copy link
Contributor

@HynoR HynoR commented Nov 24, 2025

What this PR does / why we need it?

重构swagger逻辑,老版本的swagger file还在用老方案来存储嵌入文件,把整个 swagger 塞进了内存,导致占用过量无用的开销。
swaggergo 的 files 有 v2 版本用了 embed FS来按需加载,但是包装器gin-swagger没有适配。只好自己造轮子

Summary of your change

  • 替换github.com/swaggo/files到github.com/swaggo/files/v2,该版本使用高效的 embed FS。
  • 移除过时的 github.com/swaggo/gin-swagger
  • 自造handler轮子来处理 swagger 内容

现在 core 启动时不会加载这些文件,如果用户不去访问 swagger 内容,就不会有这些东西加进内存,可以节约接近 20M 的内存开支。

但是更建议把 swagger 拆出来单独做一个服务而不是塞进 core, 这玩意99%的用户都用不上。

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Nov 24, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Nov 24, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign ssongliu for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wanghe-fit2cloud wanghe-fit2cloud merged commit 98b3dc9 into 1Panel-dev:dev-v2 Nov 24, 2025
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants