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
7e5b6dad
Commit
7e5b6dad
authored
Jun 19, 2019
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make RedisRequest derived from RedisRequestBase
parent
1eeee3d0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
192 deletions
+22
-192
CMakeLists.txt
CMakeLists.txt
+2
-1
redis.cpp
src/brpc/redis.cpp
+6
-156
redis.h
src/brpc/redis.h
+7
-35
redis_base.proto
src/brpc/redis_base.proto
+7
-0
No files found.
CMakeLists.txt
View file @
7e5b6dad
...
...
@@ -371,7 +371,8 @@ set(PROTO_FILES idl_options.proto
brpc/policy/sofa_pbrpc_meta.proto
brpc/policy/mongo.proto
brpc/trackme.proto
brpc/streaming_rpc_meta.proto
)
brpc/streaming_rpc_meta.proto
brpc/redis_base.proto
)
file
(
MAKE_DIRECTORY
${
PROJECT_BINARY_DIR
}
/output/include/brpc
)
set
(
PROTOC_FLAGS
${
PROTOC_FLAGS
}
-I
${
PROTOBUF_INCLUDE_DIR
}
)
compile_proto
(
PROTO_HDRS PROTO_SRCS
${
PROJECT_BINARY_DIR
}
...
...
src/brpc/redis.cpp
View file @
7e5b6dad
...
...
@@ -14,123 +14,23 @@
// Authors: Ge,Jun (gejun@baidu.com)
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
#include <algorithm>
#include <gflags/gflags.h>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
#include "butil/string_printf.h"
#include "butil/macros.h"
#include "brpc/controller.h"
#include <butil/status.h>
#include "brpc/redis.h"
#include "brpc/redis_command.h"
namespace
brpc
{
DEFINE_bool
(
redis_verbose_crlf2space
,
false
,
"[DEBUG] Show
\\
r
\\
n as a space"
);
// Internal implementation detail -- do not call these.
void
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_impl
();
void
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
void
protobuf_AssignDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
void
protobuf_ShutdownFile_baidu_2frpc_2fredis_5fbase_2eproto
();
namespace
{
const
::
google
::
protobuf
::
Descriptor
*
RedisRequest_descriptor_
=
NULL
;
const
::
google
::
protobuf
::
Descriptor
*
RedisResponse_descriptor_
=
NULL
;
}
// namespace
void
protobuf_AssignDesc_baidu_2frpc_2fredis_5fbase_2eproto
()
{
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
const
::
google
::
protobuf
::
FileDescriptor
*
file
=
::
google
::
protobuf
::
DescriptorPool
::
generated_pool
()
->
FindFileByName
(
"baidu/rpc/redis_base.proto"
);
GOOGLE_CHECK
(
file
!=
NULL
);
RedisRequest_descriptor_
=
file
->
message_type
(
0
);
RedisResponse_descriptor_
=
file
->
message_type
(
1
);
}
namespace
{
GOOGLE_PROTOBUF_DECLARE_ONCE
(
protobuf_AssignDescriptors_once_
);
inline
void
protobuf_AssignDescriptorsOnce
()
{
::
google
::
protobuf
::
GoogleOnceInit
(
&
protobuf_AssignDescriptors_once_
,
&
protobuf_AssignDesc_baidu_2frpc_2fredis_5fbase_2eproto
);
}
void
protobuf_RegisterTypes
(
const
::
std
::
string
&
)
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedMessage
(
RedisRequest_descriptor_
,
&
RedisRequest
::
default_instance
());
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedMessage
(
RedisResponse_descriptor_
,
&
RedisResponse
::
default_instance
());
}
}
// namespace
void
protobuf_ShutdownFile_baidu_2frpc_2fredis_5fbase_2eproto
()
{
delete
RedisRequest
::
default_instance_
;
delete
RedisResponse
::
default_instance_
;
}
void
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_impl
()
{
GOOGLE_PROTOBUF_VERIFY_VERSION
;
#if GOOGLE_PROTOBUF_VERSION >= 3002000
::
google
::
protobuf
::
internal
::
InitProtobufDefaults
();
#else
::
google
::
protobuf
::
protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto
();
#endif
::
google
::
protobuf
::
DescriptorPool
::
InternalAddGeneratedFile
(
"
\n\032
baidu/rpc/redis_base.proto
\022\t
baidu.rpc
\032
"
" google/protobuf/descriptor.proto
\"\016\n\014
Red"
"isRequest
\"\017\n\r
RedisResponseB
\003\200\001\001
"
,
111
);
::
google
::
protobuf
::
MessageFactory
::
InternalRegisterGeneratedFile
(
"baidu/rpc/redis_base.proto"
,
&
protobuf_RegisterTypes
);
RedisRequest
::
default_instance_
=
new
RedisRequest
();
RedisResponse
::
default_instance_
=
new
RedisResponse
();
RedisRequest
::
default_instance_
->
InitAsDefaultInstance
();
RedisResponse
::
default_instance_
->
InitAsDefaultInstance
();
::
google
::
protobuf
::
internal
::
OnShutdown
(
&
protobuf_ShutdownFile_baidu_2frpc_2fredis_5fbase_2eproto
);
}
GOOGLE_PROTOBUF_DECLARE_ONCE
(
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_once
);
void
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto
()
{
::
google
::
protobuf
::
GoogleOnceInit
(
&
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_once
,
&
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_impl
);
}
// Force AddDescriptors() to be called at static initialization time.
struct
StaticDescriptorInitializer_baidu_2frpc_2fredis_5fbase_2eproto
{
StaticDescriptorInitializer_baidu_2frpc_2fredis_5fbase_2eproto
()
{
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
}
}
static_descriptor_initializer_baidu_2frpc_2fredis_5fbase_2eproto_
;
// ===================================================================
#ifndef _MSC_VER
#endif // !_MSC_VER
RedisRequest
::
RedisRequest
()
:
::
google
::
protobuf
::
Message
()
{
SharedCtor
();
}
void
RedisRequest
::
InitAsDefaultInstance
()
{
:
RedisRequestBase
()
{
SharedCtor
();
}
RedisRequest
::
RedisRequest
(
const
RedisRequest
&
from
)
:
::
google
::
protobuf
::
Messag
e
()
{
:
RedisRequestBas
e
()
{
SharedCtor
();
MergeFrom
(
from
);
}
...
...
@@ -155,19 +55,6 @@ void RedisRequest::SetCachedSize(int size) const {
_cached_size_
=
size
;
GOOGLE_SAFE_CONCURRENT_WRITES_END
();
}
const
::
google
::
protobuf
::
Descriptor
*
RedisRequest
::
descriptor
()
{
protobuf_AssignDescriptorsOnce
();
return
RedisRequest_descriptor_
;
}
const
RedisRequest
&
RedisRequest
::
default_instance
()
{
if
(
default_instance_
==
NULL
)
{
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
}
return
*
default_instance_
;
}
RedisRequest
*
RedisRequest
::
default_instance_
=
NULL
;
RedisRequest
*
RedisRequest
::
New
()
const
{
return
new
RedisRequest
;
...
...
@@ -246,14 +133,6 @@ void RedisRequest::Swap(RedisRequest* other) {
}
}
::
google
::
protobuf
::
Metadata
RedisRequest
::
GetMetadata
()
const
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
Metadata
metadata
;
metadata
.
descriptor
=
RedisRequest_descriptor_
;
metadata
.
reflection
=
NULL
;
return
metadata
;
}
bool
RedisRequest
::
AddCommand
(
const
butil
::
StringPiece
&
command
)
{
if
(
_has_error
)
{
return
false
;
...
...
@@ -352,21 +231,13 @@ std::ostream& operator<<(std::ostream& os, const RedisRequest& r) {
return
os
;
}
// ===================================================================
#ifndef _MSC_VER
#endif // !_MSC_VER
RedisResponse
::
RedisResponse
()
:
::
google
::
protobuf
::
Messag
e
()
{
:
RedisResponseBas
e
()
{
SharedCtor
();
}
void
RedisResponse
::
InitAsDefaultInstance
()
{
}
RedisResponse
::
RedisResponse
(
const
RedisResponse
&
from
)
:
::
google
::
protobuf
::
Messag
e
()
{
:
RedisResponseBas
e
()
{
SharedCtor
();
MergeFrom
(
from
);
}
...
...
@@ -389,19 +260,6 @@ void RedisResponse::SharedDtor() {
void
RedisResponse
::
SetCachedSize
(
int
size
)
const
{
_cached_size_
=
size
;
}
const
::
google
::
protobuf
::
Descriptor
*
RedisResponse
::
descriptor
()
{
protobuf_AssignDescriptorsOnce
();
return
RedisResponse_descriptor_
;
}
const
RedisResponse
&
RedisResponse
::
default_instance
()
{
if
(
default_instance_
==
NULL
)
{
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
}
return
*
default_instance_
;
}
RedisResponse
*
RedisResponse
::
default_instance_
=
NULL
;
RedisResponse
*
RedisResponse
::
New
()
const
{
return
new
RedisResponse
;
...
...
@@ -505,14 +363,6 @@ void RedisResponse::Swap(RedisResponse* other) {
}
}
::
google
::
protobuf
::
Metadata
RedisResponse
::
GetMetadata
()
const
{
protobuf_AssignDescriptorsOnce
();
::
google
::
protobuf
::
Metadata
metadata
;
metadata
.
descriptor
=
RedisResponse_descriptor_
;
metadata
.
reflection
=
NULL
;
return
metadata
;
}
// ===================================================================
ParseError
RedisResponse
::
ConsumePartialIOBuf
(
butil
::
IOBuf
&
buf
,
int
reply_count
)
{
...
...
src/brpc/redis.h
View file @
7e5b6dad
...
...
@@ -18,20 +18,16 @@
#define BRPC_REDIS_H
#include <string>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_message_reflection.h>
#include "google/protobuf/descriptor.pb.h"
#include <google/protobuf/generated_message_reflection.h> // dynamic_cast_if_available
#include <google/protobuf/reflection_ops.h> // ReflectionOps::Merge
#include "butil/iobuf.h"
#include "butil/strings/string_piece.h"
#include "butil/arena.h"
#include "
redis_reply
.h"
#include "
parse_result
.h"
#include "
brpc/redis_base.pb
.h"
#include "
brpc/redis_reply
.h"
#include "brpc/parse_result.h"
namespace
brpc
{
...
...
@@ -46,7 +42,7 @@ namespace brpc {
// if (!cntl.Failed()) {
// LOG(INFO) << response.reply(0);
// }
class
RedisRequest
:
public
::
google
::
protobuf
::
Messag
e
{
class
RedisRequest
:
public
RedisRequestBas
e
{
public
:
RedisRequest
();
virtual
~
RedisRequest
();
...
...
@@ -124,10 +120,6 @@ public:
::
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
;
private
:
...
...
@@ -140,20 +132,12 @@ private:
bool
_has_error
;
// previous AddCommand had error
butil
::
IOBuf
_buf
;
// the serialized request.
mutable
int
_cached_size_
;
// ByteSize
friend
void
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_impl
();
friend
void
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
friend
void
protobuf_AssignDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
friend
void
protobuf_ShutdownFile_baidu_2frpc_2fredis_5fbase_2eproto
();
void
InitAsDefaultInstance
();
static
RedisRequest
*
default_instance_
;
};
// Response from Redis.
// Notice that a RedisResponse instance may contain multiple replies
// due to pipelining.
class
RedisResponse
:
public
::
google
::
protobuf
::
Messag
e
{
class
RedisResponse
:
public
RedisResponseBas
e
{
public
:
RedisResponse
();
virtual
~
RedisResponse
();
...
...
@@ -201,10 +185,6 @@ 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
();
...
...
@@ -215,14 +195,6 @@ private:
butil
::
Arena
_arena
;
int
_nreply
;
mutable
int
_cached_size_
;
friend
void
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_impl
();
friend
void
protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
friend
void
protobuf_AssignDesc_baidu_2frpc_2fredis_5fbase_2eproto
();
friend
void
protobuf_ShutdownFile_baidu_2frpc_2fredis_5fbase_2eproto
();
void
InitAsDefaultInstance
();
static
RedisResponse
*
default_instance_
;
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
RedisRequest
&
);
...
...
src/brpc/redis_base.proto
0 → 100644
View file @
7e5b6dad
syntax
=
"proto2"
;
import
"google/protobuf/descriptor.proto"
;
package
brpc
;
message
RedisRequestBase
{}
message
RedisResponseBase
{}
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