-
Notifications
You must be signed in to change notification settings - Fork 933
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
Ftr: Add config loader hooks for 3.0 #1370
Ftr: Add config loader hooks for 3.0 #1370
Conversation
- BeforeShutdownHook - BeforeConsumerConnectHook - ConsumerConnectSuccessHook - ConsumerConnectFailHook - AllConsumerConnectCompleteHook - BeforeProviderConnectHook - ProviderConnectSuccessHook - ProviderConnectFailHook - AllProviderConnectCompleteHook UT: - config_loader_test.TestLoadWithLoaderHooks
Codecov Report
@@ Coverage Diff @@
## 3.0 #1370 +/- ##
==========================================
+ Coverage 54.95% 55.19% +0.23%
==========================================
Files 272 273 +1
Lines 14755 14934 +179
==========================================
+ Hits 8109 8243 +134
- Misses 5769 5812 +43
- Partials 877 879 +2
Continue to review full report at Codecov.
|
|
|
hooks = []LoaderHook{} | ||
} | ||
loaderHooks[hookType] = append(hooks, hook) | ||
} |
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.
It seems that hooks
is a useless variable in this case.
if _, ok := loaderHooks[hookType]; !ok {
loaderHooks[hookType] = make([]LoaderHook)
}
loaderHooks[hookType] = append(loaderHooks[hookType], hook)
@@ -59,6 +59,8 @@ var ( | |||
confBaseFile string | |||
uniformVirtualServiceConfigPath string | |||
uniformDestRuleConfigPath string | |||
|
|||
loaderHooks map[string][]LoaderHook |
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 not initializes loaderHooks
here? If not initializes, you should handle the case that loaderHooks
is empty in AddLoaderHooks
and RemoveLoaderHooks
method.
} else { | ||
loaderHooks[hookType] = newHooks | ||
} | ||
break |
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 len(loaderHooks[hookType]) == 1 {
delete(loaderHooks, hookType)
} else {
loaderHooks[hookType] = append(loaderHooks[hookType][:index], loaderHooks[hookType][index+1:]...)
}
) | ||
|
||
const ( | ||
hookParams = constant.HookParams |
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.
use constant.HookParams
directly please
暂时先关闭,后期改进 |
What this PR does:
Hook Type:
Create Instance:
Add/Remove Hooks:
Unit Test:
Which issue(s) this PR fixes:
Fixes #1364
Special notes for your reviewer:
Does this PR introduce a user-facing change?: