-
Notifications
You must be signed in to change notification settings - Fork 438
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
Conversation
pkg/adapters/goframe/go.mod
Outdated
@@ -0,0 +1,54 @@ | |||
module github.com/alibaba/sentinel-golang/pkg/adapters/goframe | |||
|
|||
go 1.20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plz downgrade the go version to no higher than 1.18 to keep it consistent with main package, so as to avoid introducing new features now or in the future and support more go versions
pkg/adapters/goframe/middleware.go
Outdated
if extractedName == "" { | ||
extractedName = resourceName | ||
} | ||
resourceName = extractedName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if extractedName := options.resourceExtract(r); extractedName != "" {
resourceName = extractedName
}
It looks the same as the code logic above? But readability will be improved
tangfangchun seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
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.运行测试用例:
2.手动测试:
Special notes for reviews