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
d8893d43
Commit
d8893d43
authored
Oct 25, 2018
by
TousakaRin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix codestyle
parent
5d440eb9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
circuit_breaker.cpp
src/brpc/circuit_breaker.cpp
+4
-3
circuit_breaker.h
src/brpc/circuit_breaker.h
+2
-2
No files found.
src/brpc/circuit_breaker.cpp
View file @
d8893d43
...
...
@@ -180,11 +180,12 @@ void CircuitBreaker::Reset() {
_long_window
.
Reset
();
_short_window
.
Reset
();
_last_reset_time_ms
=
butil
::
cpuwide_time_ms
();
_broken
.
store
(
false
,
butil
::
memory_order_release
);
}
void
CircuitBreaker
::
MarkAsBroken
()
{
if
(
_broken
.
exchange
(
true
,
butil
::
memory_order_acquire
))
{
_isolated_times
.
fetch_add
(
butil
::
memory_order_relaxed
);
if
(
!
_broken
.
exchange
(
true
,
butil
::
memory_order_acquire
))
{
_isolated_times
.
fetch_add
(
1
,
butil
::
memory_order_relaxed
);
UpdateIsolationDuration
();
}
}
...
...
@@ -194,8 +195,8 @@ int CircuitBreaker::health_score() const {
}
void
CircuitBreaker
::
UpdateIsolationDuration
()
{
int
isolation_duration_ms
=
_isolation_duration_ms
.
load
(
butil
::
memory_order_relaxed
);
int64_t
now_time_ms
=
butil
::
cpuwide_time_ms
();
int
isolation_duration_ms
=
_isolation_duration_ms
.
load
(
butil
::
memory_order_relaxed
);
const
int
max_isolation_duration_ms
=
FLAGS_circuit_breaker_max_isolation_duration_ms
;
const
int
min_isolation_duration_ms
=
...
...
src/brpc/circuit_breaker.h
View file @
d8893d43
...
...
@@ -33,12 +33,12 @@ public:
// latency: Time cost of this call.
// Note: Once OnCallEnd() determined that a node needs to be isolated,
// it will always return false until you call Reset(). Usually Reset()
// will be called in the health check thread.
// will be called in the health check thread.
bool
OnCallEnd
(
int
error_code
,
int64_t
latency
);
// Reset CircuitBreaker and clear history data. will erase the historical
// data and start sampling again. Before you call this method, you need to
// ensure that no one else is
calling OnCallEnd
.
// ensure that no one else is
accessing CircuitBreaker
.
void
Reset
();
// Mark the Socket as broken. Call this method when you want to isolate a
...
...
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