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
8b2edf4e
Commit
8b2edf4e
authored
Mar 20, 2019
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
health_check_using_rpc: refine comment
parent
084c1e7a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
8 deletions
+17
-8
controller.h
src/brpc/controller.h
+3
-1
socket.cpp
src/brpc/socket.cpp
+7
-4
socket.h
src/brpc/socket.h
+7
-3
No files found.
src/brpc/controller.h
View file @
8b2edf4e
...
...
@@ -325,7 +325,9 @@ public:
bool
is_done_allowed_to_run_in_place
()
const
{
return
has_flag
(
FLAGS_ALLOW_DONE_TO_RUN_IN_PLACE
);
}
// TODO(zhujiahsun): comment
// Tell RPC that this particular call is used to do health check. These two
// functions is used by the developers of brpc and should not be touched or
// called by users.
void
set_health_check_call
(
bool
f
)
{
set_flag
(
FLAGS_HEALTH_CHECK_CALL
,
f
);
}
bool
has_health_check_call
()
const
{
return
has_flag
(
FLAGS_HEALTH_CHECK_CALL
);
}
...
...
src/brpc/socket.cpp
View file @
8b2edf4e
...
...
@@ -94,9 +94,12 @@ DEFINE_int32(connect_timeout_as_unreachable, 3,
"times *continuously*, the error is changed to ENETUNREACH which "
"fails the main socket as well when this socket is pooled."
);
DEFINE_bool
(
health_check_using_rpc
,
false
,
"todo"
);
DEFINE_string
(
health_check_path
,
"/health"
,
"todo"
);
DEFINE_int32
(
health_check_timeout_ms
,
300
,
"todo"
);
DEFINE_bool
(
health_check_using_rpc
,
false
,
"By default health check succeeds if server"
"can be connected. If this flag is set, health check is completed not only"
"when server can be connected but also an additional http call succeeds"
"indicated by FLAGS_health_check_path and FLAGS_health_check_timeout_ms"
);
DEFINE_string
(
health_check_path
,
"/health"
,
"Http path of health check call"
);
DEFINE_int32
(
health_check_timeout_ms
,
300
,
"Timeout of health check call"
);
static
bool
validate_connect_timeout_as_unreachable
(
const
char
*
,
int32_t
v
)
{
return
v
>=
2
&&
v
<
1000
/*large enough*/
;
...
...
@@ -1045,7 +1048,7 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) {
options
.
timeout_ms
=
FLAGS_health_check_timeout_ms
;
brpc
::
Channel
channel
;
if
(
channel
.
Init
(
_id
,
&
options
)
!=
0
)
{
// SetFailed
() again
to trigger next round of health checking
// SetFailed to trigger next round of health checking
ptr
->
SetFailed
();
return
false
;
}
...
...
src/brpc/socket.h
View file @
8b2edf4e
...
...
@@ -349,8 +349,12 @@ public:
void
SetLogOff
();
bool
IsLogOff
()
const
;
// TODO(zhujiashun)
// Check Whether the state is in health check using rpc state or
// not, which means this socket would not be selected in further
// user request until rpc succeed and can only be used by health
// check rpc call.
bool
IsHealthCheckingUsingRPC
()
const
;
// Reset health check state to the initial state(which is false)
void
ResetHealthCheckingUsingRPC
();
// Start to process edge-triggered events from the fd.
...
...
@@ -795,8 +799,8 @@ private:
butil
::
Mutex
_stream_mutex
;
std
::
set
<
StreamId
>
*
_stream_set
;
// If this flag is set,
then the current socket is used to health check
// a
nd should not health check again
// If this flag is set,
socket is now in health check state using
// a
pplication-level rpc.
butil
::
atomic
<
bool
>
_health_checking_using_rpc
;
};
...
...
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