Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
ef3ee436
Commit
ef3ee436
authored
Dec 29, 2019
by
Soultz
Committed by
helei
Jan 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ignore ELIMIT for circuit breaker
parent
1d29f21b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
circuit_breaker.cpp
src/brpc/circuit_breaker.cpp
+9
-7
No files found.
src/brpc/circuit_breaker.cpp
View file @
ef3ee436
...
...
@@ -17,6 +17,8 @@
#include "brpc/circuit_breaker.h"
#include "brpc/circuit_breaker.h"
#include <cmath>
#include <mutex>
#include <gflags/gflags.h>
...
...
@@ -27,9 +29,9 @@
namespace
brpc
{
DEFINE_string
(
circuit_breaker_ignored_error_codes
,
"2004"
,
"Comma sparated error code list, those error codes will be ignored by"
"circuit breaker. Note that you should never ignore 0, we ignored ELIMIT for default."
);
DEFINE_string
(
circuit_breaker_ignored_error_codes
,
"2004"
,
"Comma sparated error code list, those error codes will be ignored by"
"circuit breaker. Note that you should never ignore 0, we ignored ELIMIT for default."
);
DEFINE_int32
(
circuit_breaker_short_window_size
,
1500
,
"Short window sample size."
);
DEFINE_int32
(
circuit_breaker_long_window_size
,
3000
,
...
...
@@ -68,18 +70,18 @@ namespace {
std
::
once_flag
g_init_ignored_error_codes_once
;
std
::
set
<
int
>
g_ignored_error_codes
;
void
InitIgoredErrorCodes
()
{
void
InitIg
n
oredErrorCodes
()
{
std
::
vector
<
std
::
string
>
error_codes
;
SplitString
(
FLAGS_circuit_breaker_ignored_error_codes
,
','
,
&
error_codes
);
for
(
const
std
::
string
&
str
:
error_codes
)
{
int
error_code
=
0
;
if
(
!
butil
::
StringToInt
(
str
,
&
error_code
)
||
error_code
==
0
)
{
LOG
(
ERROR
)
<<
"Invalid error code '"
<<
str
LOG
(
ERROR
)
<<
"Invalid error code '"
<<
str
<<
"', check the value of flag 'circuit_breaker_ignored_error_code': "
<<
FLAGS_circuit_breaker_ignored_error_codes
;
continue
;
}
g_ignored_error_codes
.
insert
(
error_code
);
g_ignored_error_codes
.
insert
(
error_code
);
}
}
...
...
@@ -198,7 +200,7 @@ CircuitBreaker::CircuitBreaker()
}
bool
CircuitBreaker
::
OnCallEnd
(
int
error_code
,
int64_t
latency
)
{
std
::
call_once
(
g_init_ignored_error_codes_once
,
InitIgoredErrorCodes
);
std
::
call_once
(
g_init_ignored_error_codes_once
,
InitIg
n
oredErrorCodes
);
if
(
g_ignored_error_codes
.
find
(
error_code
)
!=
g_ignored_error_codes
.
end
())
{
return
true
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment