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
f01330d5
Commit
f01330d5
authored
Nov 19, 2018
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split part of Renew() into do_renew
parent
a73bbdf9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
25 deletions
+32
-25
discovery_naming_service.cpp
src/brpc/policy/discovery_naming_service.cpp
+29
-23
discovery_naming_service.h
src/brpc/policy/discovery_naming_service.h
+3
-2
No files found.
src/brpc/policy/discovery_naming_service.cpp
View file @
f01330d5
...
...
@@ -247,6 +247,32 @@ int ParseCommonResult(const butil::IOBuf& buf, std::string* error_text) {
return
code
;
}
int
DiscoveryClient
::
do_renew
()
const
{
Controller
cntl
;
cntl
.
http_request
().
set_method
(
HTTP_METHOD_POST
);
cntl
.
http_request
().
uri
()
=
"/discovery/renew"
;
cntl
.
http_request
().
set_content_type
(
"application/x-www-form-urlencoded"
);
butil
::
IOBufBuilder
os
;
os
<<
"appid="
<<
_appid
<<
"&hostname="
<<
_hostname
<<
"&env="
<<
_env
<<
"®ion="
<<
_region
<<
"&zone="
<<
_zone
;
os
.
move_to
(
cntl
.
request_attachment
());
s_discovery_channel
.
CallMethod
(
NULL
,
&
cntl
,
NULL
,
NULL
,
NULL
);
if
(
cntl
.
Failed
())
{
LOG
(
ERROR
)
<<
"Fail to post /discovery/renew: "
<<
cntl
.
ErrorText
();
return
-
1
;
}
std
::
string
error_text
;
if
(
ParseCommonResult
(
cntl
.
response_attachment
(),
&
error_text
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to renew "
<<
_hostname
<<
" to "
<<
_appid
<<
": "
<<
error_text
;
return
-
1
;
}
return
0
;
}
void
*
DiscoveryClient
::
PeriodicRenew
(
void
*
arg
)
{
DiscoveryClient
*
d
=
static_cast
<
DiscoveryClient
*>
(
arg
);
int
consecutive_renew_error
=
0
;
...
...
@@ -287,27 +313,7 @@ void* DiscoveryClient::PeriodicRenew(void* arg) {
consecutive_renew_error
=
0
;
}
Controller
cntl
;
cntl
.
http_request
().
set_method
(
HTTP_METHOD_POST
);
cntl
.
http_request
().
uri
()
=
"/discovery/renew"
;
cntl
.
http_request
().
set_content_type
(
"application/x-www-form-urlencoded"
);
butil
::
IOBufBuilder
os
;
os
<<
"appid="
<<
d
->
_appid
<<
"&hostname="
<<
d
->
_hostname
<<
"&env="
<<
d
->
_env
<<
"®ion="
<<
d
->
_region
<<
"&zone="
<<
d
->
_zone
;
os
.
move_to
(
cntl
.
request_attachment
());
s_discovery_channel
.
CallMethod
(
NULL
,
&
cntl
,
NULL
,
NULL
,
NULL
);
if
(
cntl
.
Failed
())
{
LOG
(
ERROR
)
<<
"Fail to post /discovery/renew: "
<<
cntl
.
ErrorText
();
consecutive_renew_error
++
;
continue
;
}
std
::
string
error_text
;
if
(
ParseCommonResult
(
cntl
.
response_attachment
(),
&
error_text
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to renew "
<<
d
->
_hostname
<<
" to "
<<
d
->
_appid
<<
": "
<<
error_text
;
if
(
d
->
do_renew
()
!=
0
)
{
consecutive_renew_error
++
;
continue
;
}
...
...
@@ -391,7 +397,7 @@ int DiscoveryClient::Register(const DiscoveryRegisterParam& req) {
return
0
;
}
int
DiscoveryClient
::
do_register
()
{
int
DiscoveryClient
::
do_register
()
const
{
Controller
cntl
;
cntl
.
http_request
().
set_method
(
HTTP_METHOD_POST
);
cntl
.
http_request
().
uri
()
=
"/discovery/register"
;
...
...
@@ -445,7 +451,7 @@ int DiscoveryClient::Cancel() {
return
do_cancel
();
}
int
DiscoveryClient
::
do_cancel
()
{
int
DiscoveryClient
::
do_cancel
()
const
{
pthread_once
(
&
s_init_channel_once
,
InitChannel
);
Controller
cntl
;
cntl
.
http_request
().
set_method
(
HTTP_METHOD_POST
);
...
...
src/brpc/policy/discovery_naming_service.h
View file @
f01330d5
...
...
@@ -63,8 +63,9 @@ public:
private
:
static
void
*
PeriodicRenew
(
void
*
arg
);
int
do_cancel
();
int
do_register
();
int
do_cancel
()
const
;
int
do_register
()
const
;
int
do_renew
()
const
;
private
:
enum
State
{
...
...
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