Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22a7f0099
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
22a7f0099
Commits
31b1241d
Commit
31b1241d
authored
4 years ago
by
YGrylls
Browse files
Options
Downloads
Patches
Plain Diff
add detailed comment
parent
426ba750
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
filter/filter_impl/hystrix_filter.go
+45
-5
45 additions, 5 deletions
filter/filter_impl/hystrix_filter.go
with
45 additions
and
5 deletions
filter/filter_impl/hystrix_filter.go
+
45
−
5
View file @
31b1241d
...
...
@@ -81,7 +81,47 @@ func NewHystrixFilterError(err error, failByHystrix bool) error {
}
}
// nolint
/**
* HystrixFilter
* You should add hystrix related configuration in provider or consumer config or both, according to which side you are to apply HystrixFilter.
* For example:
* filter_conf:
* hystrix:
* configs:
* # =========== Define config here ============
* "Default":
* timeout : 1000
* max_concurrent_requests : 25
* sleep_window : 5000
* error_percent_threshold : 50
* request_volume_threshold: 20
* "userp":
* timeout: 2000
* max_concurrent_requests: 512
* sleep_window: 4000
* error_percent_threshold: 35
* request_volume_threshold: 6
* "userp_m":
* timeout : 1200
* max_concurrent_requests : 512
* sleep_window : 6000
* error_percent_threshold : 60
* request_volume_threshold: 16
* # =========== Define error whitelist which will be ignored by Hystrix counter ============
* error_whitelist: [".*exception.*"]
*
* # =========== Apply default config here ===========
* default: "Default"
*
* services:
* "com.ikurento.user.UserProvider":
* # =========== Apply service level config ===========
* service_config: "userp"
* # =========== Apply method level config ===========
* methods:
* "GetUser": "userp_m"
* "GetUser1": "userp_m"
*/
type
HystrixFilter
struct
{
COrP
bool
//true for consumer
res
map
[
string
][]
*
regexp
.
Regexp
...
...
@@ -209,11 +249,11 @@ func getConfig(service string, method string, cOrP bool) CommandConfigWithError
func
initHystrixConfigConsumer
()
error
{
if
config
.
GetConsumerConfig
()
.
FilterConf
==
nil
{
return
perrors
.
Errorf
(
"no config for hystrix"
)
return
perrors
.
Errorf
(
"no config for hystrix
_consumer
"
)
}
filterConfig
:=
config
.
GetConsumerConfig
()
.
FilterConf
.
(
map
[
interface
{}]
interface
{})[
HYSTRIX
]
if
filterConfig
==
nil
{
return
perrors
.
Errorf
(
"no config for hystrix"
)
return
perrors
.
Errorf
(
"no config for hystrix
_consumer
"
)
}
hystrixConfByte
,
err
:=
yaml
.
Marshal
(
filterConfig
)
if
err
!=
nil
{
...
...
@@ -228,11 +268,11 @@ func initHystrixConfigConsumer() error {
func
initHystrixConfigProvider
()
error
{
if
config
.
GetProviderConfig
()
.
FilterConf
==
nil
{
return
perrors
.
Errorf
(
"no config for hystrix"
)
return
perrors
.
Errorf
(
"no config for hystrix
_provider
"
)
}
filterConfig
:=
config
.
GetProviderConfig
()
.
FilterConf
.
(
map
[
interface
{}]
interface
{})[
HYSTRIX
]
if
filterConfig
==
nil
{
return
perrors
.
Errorf
(
"no config for hystrix"
)
return
perrors
.
Errorf
(
"no config for hystrix
_provider
"
)
}
hystrixConfByte
,
err
:=
yaml
.
Marshal
(
filterConfig
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment