-
Notifications
You must be signed in to change notification settings - Fork 5
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
config-file part degradation #9
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: yueyuetangg 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 |
README.md
Outdated
{ | ||
"degradation": { | ||
"enabled": true, | ||
"percentage": 0 |
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.
Setting percentage as 0 is kinda weird when degradation is enabled.
It's a good idea to make the documentation more uniform, see config-etcd, etc.
README.md
Outdated
}, | ||
"degradation": { | ||
"enabled": true, | ||
"percentage": 0 |
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.
ditto.
README_CN.md
Outdated
{ | ||
"degradation": { | ||
"enabled": true, | ||
"percentage": 0 |
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.
ditto.
README_CN.md
Outdated
}, | ||
"degradation": { | ||
"enabled": true, | ||
"percentage": 0 |
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.
ditto.
pkg/degradation.go
Outdated
|
||
// EqualsTo returns true if the current Config equals to the other Config | ||
func (c *DegradationConfig) EqualsTo(other iface.ConfigValueItem) bool { | ||
o := other.(*DegradationConfig) |
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.
Had better check whether c == nil.
|
||
func (c *Container) GetAclRule() acl.RejectFunc { | ||
return func(ctx context.Context, request interface{}) (reason error) { | ||
cfg := c.config.Load().(*DegradationConfig) |
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.
When users do not configure degration in kitex_client.json, this cfg would be nil.
You can take a try.
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.
Actually, you just need to check whether cfg == nil here.
Timeout map[string]*rpctimeout.RPCTimeout `mapstructure:"timeout"` // key: method, "*" for default | ||
Retry map[string]*retry.Policy `mapstructure:"retry"` // key: method, "*" for default | ||
Circuitbreaker map[string]*circuitbreak.CBConfig `mapstructure:"circuitbreaker"` // key: method | ||
Degradation map[string]*degradation.DegradationConfig `mapstructure:"degradation"` |
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.
Why did you use map?
|
||
func (c *Container) GetAclRule() acl.RejectFunc { | ||
return func(ctx context.Context, request interface{}) (reason error) { | ||
cfg := c.config.Load().(*DegradationConfig) |
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.
Actually, you just need to check whether cfg == nil here.
What type of PR is this?
Check the PR title.
(Optional) Translate the PR title into Chinese.
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en:
zh(optional):
(Optional) Which issue(s) this PR fixes:
(optional) The PR that updates user documentation: