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
231b35af
Commit
231b35af
authored
Jun 19, 2019
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make RedisRequestBase be member of RedisRequest
parent
7e5b6dad
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
30 deletions
+65
-30
baidu_rpc_protocol.cpp
src/brpc/policy/baidu_rpc_protocol.cpp
+6
-6
hulu_pbrpc_protocol.cpp
src/brpc/policy/hulu_pbrpc_protocol.cpp
+6
-6
sofa_pbrpc_protocol.cpp
src/brpc/policy/sofa_pbrpc_protocol.cpp
+3
-3
progressive_attachment.h
src/brpc/progressive_attachment.h
+1
-0
redis.cpp
src/brpc/redis.cpp
+36
-13
redis.h
src/brpc/redis.h
+13
-2
No files found.
src/brpc/policy/baidu_rpc_protocol.cpp
View file @
231b35af
...
...
@@ -317,12 +317,12 @@ void ProcessRpcRequest(InputMessageBase* msg_base) {
SampledRequest
*
sample
=
AskToBeSampled
();
if
(
sample
)
{
sample
->
set_service_name
(
request_meta
.
service_name
());
sample
->
set_method_name
(
request_meta
.
method_name
());
sample
->
set_compress_type
((
CompressType
)
meta
.
compress_type
());
sample
->
set_protocol_type
(
PROTOCOL_BAIDU_STD
);
sample
->
set_attachment_size
(
meta
.
attachment_size
());
sample
->
set_authentication_data
(
meta
.
authentication_data
());
sample
->
meta
.
set_service_name
(
request_meta
.
service_name
());
sample
->
meta
.
set_method_name
(
request_meta
.
method_name
());
sample
->
meta
.
set_compress_type
((
CompressType
)
meta
.
compress_type
());
sample
->
meta
.
set_protocol_type
(
PROTOCOL_BAIDU_STD
);
sample
->
meta
.
set_attachment_size
(
meta
.
attachment_size
());
sample
->
meta
.
set_authentication_data
(
meta
.
authentication_data
());
sample
->
request
=
msg
->
payload
;
sample
->
submit
(
start_parse_us
);
}
...
...
src/brpc/policy/hulu_pbrpc_protocol.cpp
View file @
231b35af
...
...
@@ -345,15 +345,15 @@ void ProcessHuluRequest(InputMessageBase* msg_base) {
const
CompressType
req_cmp_type
=
Hulu2CompressType
((
HuluCompressType
)
meta
.
compress_type
());
SampledRequest
*
sample
=
AskToBeSampled
();
if
(
sample
)
{
sample
->
set_service_name
(
meta
.
service_name
());
sample
->
set_method_index
(
meta
.
method_index
());
sample
->
set_compress_type
(
req_cmp_type
);
sample
->
set_protocol_type
(
PROTOCOL_HULU_PBRPC
);
sample
->
set_user_data
(
meta
.
user_data
());
sample
->
meta
.
set_service_name
(
meta
.
service_name
());
sample
->
meta
.
set_method_index
(
meta
.
method_index
());
sample
->
meta
.
set_compress_type
(
req_cmp_type
);
sample
->
meta
.
set_protocol_type
(
PROTOCOL_HULU_PBRPC
);
sample
->
meta
.
set_user_data
(
meta
.
user_data
());
if
(
meta
.
has_user_message_size
()
&&
static_cast
<
size_t
>
(
meta
.
user_message_size
())
<
msg
->
payload
.
size
())
{
size_t
attachment_size
=
msg
->
payload
.
size
()
-
meta
.
user_message_size
();
sample
->
set_attachment_size
(
attachment_size
);
sample
->
meta
.
set_attachment_size
(
attachment_size
);
}
sample
->
request
=
msg
->
payload
;
sample
->
submit
(
start_parse_us
);
...
...
src/brpc/policy/sofa_pbrpc_protocol.cpp
View file @
231b35af
...
...
@@ -322,9 +322,9 @@ void ProcessSofaRequest(InputMessageBase* msg_base) {
SampledRequest
*
sample
=
AskToBeSampled
();
if
(
sample
)
{
sample
->
set_method_name
(
meta
.
method
());
sample
->
set_compress_type
(
req_cmp_type
);
sample
->
set_protocol_type
(
PROTOCOL_SOFA_PBRPC
);
sample
->
meta
.
set_method_name
(
meta
.
method
());
sample
->
meta
.
set_compress_type
(
req_cmp_type
);
sample
->
meta
.
set_protocol_type
(
PROTOCOL_SOFA_PBRPC
);
sample
->
request
=
msg
->
payload
;
sample
->
submit
(
start_parse_us
);
}
...
...
src/brpc/progressive_attachment.h
View file @
231b35af
...
...
@@ -17,6 +17,7 @@
#ifndef BRPC_PROGRESSIVE_ATTACHMENT_H
#define BRPC_PROGRESSIVE_ATTACHMENT_H
#include <google/protobuf/stubs/callback.h>
#include "butil/atomicops.h"
#include "butil/iobuf.h"
#include "butil/endpoint.h" // butil::EndPoint
...
...
src/brpc/redis.cpp
View file @
231b35af
...
...
@@ -24,13 +24,12 @@ namespace brpc {
DEFINE_bool
(
redis_verbose_crlf2space
,
false
,
"[DEBUG] Show
\\
r
\\
n as a space"
);
RedisRequest
::
RedisRequest
()
:
RedisRequestBase
()
{
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
}
RedisRequest
::
RedisRequest
(
const
RedisRequest
&
from
)
:
RedisRequestBas
e
()
{
:
::
google
::
protobuf
::
Messag
e
()
{
SharedCtor
();
MergeFrom
(
from
);
}
...
...
@@ -46,14 +45,10 @@ RedisRequest::~RedisRequest() {
}
void
RedisRequest
::
SharedDtor
()
{
if
(
this
!=
default_instance_
)
{
}
}
void
RedisRequest
::
SetCachedSize
(
int
size
)
const
{
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN
();
_cached_size_
=
size
;
GOOGLE_SAFE_CONCURRENT_WRITES_END
();
}
RedisRequest
*
RedisRequest
::
New
()
const
{
...
...
@@ -84,9 +79,7 @@ void RedisRequest::SerializeWithCachedSizes(
int
RedisRequest
::
ByteSize
()
const
{
int
total_size
=
_buf
.
size
();
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN
();
_cached_size_
=
total_size
;
GOOGLE_SAFE_CONCURRENT_WRITES_END
();
return
total_size
;
}
...
...
@@ -206,6 +199,22 @@ bool RedisRequest::SerializeTo(butil::IOBuf* buf) const {
return
true
;
}
const
::
google
::
protobuf
::
Descriptor
*
RedisRequest
::
descriptor
()
{
return
_base
.
GetDescriptor
();
}
const
RedisRequest
&
RedisRequest
::
default_instance
()
{
static
RedisRequest
req
;
return
req
;
}
::
google
::
protobuf
::
Metadata
RedisRequest
::
GetMetadata
()
const
{
::
google
::
protobuf
::
Metadata
metadata
;
metadata
.
descriptor
=
_base
.
GetDescriptor
();
metadata
.
reflection
=
_base
.
GetReflection
();
return
metadata
;
}
void
RedisRequest
::
Print
(
std
::
ostream
&
os
)
const
{
butil
::
IOBuf
cp
=
_buf
;
butil
::
IOBuf
seg
;
...
...
@@ -232,12 +241,12 @@ std::ostream& operator<<(std::ostream& os, const RedisRequest& r) {
}
RedisResponse
::
RedisResponse
()
:
RedisResponseBas
e
()
{
:
::
google
::
protobuf
::
Messag
e
()
{
SharedCtor
();
}
RedisResponse
::
RedisResponse
(
const
RedisResponse
&
from
)
:
RedisResponseBas
e
()
{
:
::
google
::
protobuf
::
Messag
e
()
{
SharedCtor
();
MergeFrom
(
from
);
}
...
...
@@ -253,8 +262,6 @@ RedisResponse::~RedisResponse() {
}
void
RedisResponse
::
SharedDtor
()
{
if
(
this
!=
default_instance_
)
{
}
}
void
RedisResponse
::
SetCachedSize
(
int
size
)
const
{
...
...
@@ -363,6 +370,22 @@ void RedisResponse::Swap(RedisResponse* other) {
}
}
const
::
google
::
protobuf
::
Descriptor
*
RedisResponse
::
descriptor
()
{
return
_base
.
GetDescriptor
();
}
const
RedisResponse
&
RedisResponse
::
default_instance
()
{
static
RedisResponse
res
;
return
res
;
}
::
google
::
protobuf
::
Metadata
RedisResponse
::
GetMetadata
()
const
{
::
google
::
protobuf
::
Metadata
metadata
;
metadata
.
descriptor
=
_base
.
GetDescriptor
();
metadata
.
reflection
=
_base
.
GetReflection
();
return
metadata
;
}
// ===================================================================
ParseError
RedisResponse
::
ConsumePartialIOBuf
(
butil
::
IOBuf
&
buf
,
int
reply_count
)
{
...
...
src/brpc/redis.h
View file @
231b35af
...
...
@@ -19,6 +19,7 @@
#include <string>
#include <google/protobuf/message.h>
#include <google/protobuf/generated_message_reflection.h> // dynamic_cast_if_available
#include <google/protobuf/reflection_ops.h> // ReflectionOps::Merge
...
...
@@ -42,7 +43,7 @@ namespace brpc {
// if (!cntl.Failed()) {
// LOG(INFO) << response.reply(0);
// }
class
RedisRequest
:
public
RedisRequestBas
e
{
class
RedisRequest
:
public
::
google
::
protobuf
::
Messag
e
{
public
:
RedisRequest
();
virtual
~
RedisRequest
();
...
...
@@ -119,6 +120,10 @@ public:
::
google
::
protobuf
::
io
::
CodedOutputStream
*
output
)
const
;
::
google
::
protobuf
::
uint8
*
SerializeWithCachedSizesToArray
(
::
google
::
protobuf
::
uint8
*
output
)
const
;
int
GetCachedSize
()
const
{
return
_cached_size_
;
}
static
const
::
google
::
protobuf
::
Descriptor
*
descriptor
();
static
const
RedisRequest
&
default_instance
();
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
;
void
Print
(
std
::
ostream
&
)
const
;
...
...
@@ -132,12 +137,13 @@ private:
bool
_has_error
;
// previous AddCommand had error
butil
::
IOBuf
_buf
;
// the serialized request.
mutable
int
_cached_size_
;
// ByteSize
static
RedisRequestBase
_base
;
};
// Response from Redis.
// Notice that a RedisResponse instance may contain multiple replies
// due to pipelining.
class
RedisResponse
:
public
RedisResponseBas
e
{
class
RedisResponse
:
public
::
google
::
protobuf
::
Messag
e
{
public
:
RedisResponse
();
virtual
~
RedisResponse
();
...
...
@@ -185,6 +191,10 @@ public:
::
google
::
protobuf
::
uint8
*
SerializeWithCachedSizesToArray
(
::
google
::
protobuf
::
uint8
*
output
)
const
;
int
GetCachedSize
()
const
{
return
_cached_size_
;
}
static
const
::
google
::
protobuf
::
Descriptor
*
descriptor
();
static
const
RedisResponse
&
default_instance
();
::
google
::
protobuf
::
Metadata
GetMetadata
()
const
;
private
:
void
SharedCtor
();
void
SharedDtor
();
...
...
@@ -195,6 +205,7 @@ private:
butil
::
Arena
_arena
;
int
_nreply
;
mutable
int
_cached_size_
;
static
RedisResponseBase
_base
;
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
RedisRequest
&
);
...
...
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