Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(goframe): add sentinel adapter for goframe #587

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tangfc
Copy link

@tangfc tangfc commented Dec 18, 2024

Describe what this PR does / why we need it

这个 PR 为 Sentinel 添加了 goframe 框架的适配器。通过这个适配器,开发者可以在 goframe 项目中方便地使用 Sentinel 的限流和
熔断功能,提高系统的稳定性和可靠性。

Does this pull request fix one issue?

NONE

Describe how you did it

1.实现了 SentinelMiddleware 函数,用于在 goframe 框架中集成 Sentinel。
2.添加了withResourceExtractor 选项,允许开发者自定义资源提取逻辑。
3.添加了WithBlockFallback 选项,允许开发者自定义阻塞时的回退逻辑。
4.编写了相应的测试用例,确保适配器的正确性和稳定性。

Describe how to verify it

1.运行测试用例:

  • go test -run ^TestSentinelMiddlewareDefault -v
  • go test -run ^TestSentineIMiddlewareExtractor -v
  • go test -run ^TestSentinelMiddlewareFallback -v

2.手动测试:

  • 启动一个 goframe应用,集成SentinelMiddleware。
  • 发送请求并观察限流和熔断效果。
  • 测试 WithBlockFallback 选项的回退逻辑。

Special notes for reviews

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