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
0c96ecef
Commit
0c96ecef
authored
Nov 21, 2019
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redis_server_protocol: rename RedisReply to RedisMessage
parent
978814fe
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
18 deletions
+18
-18
redis_protocol.cpp
src/brpc/policy/redis_protocol.cpp
+4
-4
redis.cpp
src/brpc/redis.cpp
+7
-7
redis.h
src/brpc/redis.h
+7
-7
redis_message.cpp
src/brpc/redis_message.cpp
+0
-0
redis_message.h
src/brpc/redis_message.h
+0
-0
brpc_redis_unittest.cpp
test/brpc_redis_unittest.cpp
+0
-0
No files found.
src/brpc/policy/redis_protocol.cpp
View file @
0c96ecef
...
...
@@ -54,7 +54,7 @@ struct InputResponse : public InputMessageBase {
};
struct
ExecutionQueueContext
{
Redis
Reply
message
;
Redis
Message
message
;
SocketId
socket_id
;
butil
::
Arena
arena
;
};
...
...
@@ -72,7 +72,7 @@ int Consume(void* meta, bthread::TaskIterator<ExecutionQueueContext*>& iter) {
LOG
(
WARNING
)
<<
"Fail to address redis socket"
;
continue
;
}
Redis
Reply
output
;
Redis
Message
output
;
conn
->
OnRedisMessage
(
ctx
->
message
,
&
output
,
&
ctx
->
arena
);
butil
::
IOBuf
sendbuf
;
output
.
SerializeToIOBuf
(
&
sendbuf
);
...
...
@@ -132,7 +132,7 @@ ParseResult ParseRedisMessage(butil::IOBuf* source, Socket* socket,
socket
->
reset_parsing_context
(
ctx
);
}
std
::
unique_ptr
<
ExecutionQueueContext
>
task
(
new
ExecutionQueueContext
);
Redis
Reply
message
;
Redis
Message
message
;
ParseError
err
=
message
.
ConsumePartialIOBuf
(
*
source
,
&
task
->
arena
);
if
(
err
!=
PARSE_OK
)
{
return
MakeParseError
(
err
);
...
...
@@ -178,7 +178,7 @@ ParseResult ParseRedisMessage(butil::IOBuf* source, Socket* socket,
if
(
pi
.
with_auth
)
{
if
(
msg
->
response
.
reply_size
()
!=
1
||
!
(
msg
->
response
.
reply
(
0
).
type
()
==
brpc
::
REDIS_
REPLY
_STATUS
&&
!
(
msg
->
response
.
reply
(
0
).
type
()
==
brpc
::
REDIS_
MESSAGE
_STATUS
&&
msg
->
response
.
reply
(
0
).
data
().
compare
(
"OK"
)
==
0
))
{
LOG
(
ERROR
)
<<
"Redis Auth failed: "
<<
msg
->
response
;
return
MakeParseError
(
PARSE_ERROR_NO_RESOURCE
,
...
...
src/brpc/redis.cpp
View file @
0c96ecef
...
...
@@ -322,10 +322,10 @@ void RedisResponse::MergeFrom(const RedisResponse& from) {
_nreply
=
new_nreply
;
return
;
}
Redis
Reply
*
new_others
=
(
Redis
Reply
*
)
_arena
.
allocate
(
sizeof
(
RedisReply
)
*
(
new_nreply
-
1
));
Redis
Message
*
new_others
=
(
Redis
Message
*
)
_arena
.
allocate
(
sizeof
(
RedisMessage
)
*
(
new_nreply
-
1
));
for
(
int
i
=
0
;
i
<
new_nreply
-
1
;
++
i
)
{
new
(
new_others
+
i
)
Redis
Reply
;
new
(
new_others
+
i
)
Redis
Message
;
}
int
new_other_index
=
0
;
for
(
int
i
=
1
;
i
<
_nreply
;
++
i
)
{
...
...
@@ -394,14 +394,14 @@ ParseError RedisResponse::ConsumePartialIOBuf(butil::IOBuf& buf, int reply_count
}
if
(
reply_count
>
1
)
{
if
(
_other_replies
==
NULL
)
{
_other_replies
=
(
Redis
Reply
*
)
_arena
.
allocate
(
sizeof
(
Redis
Reply
)
*
(
reply_count
-
1
));
_other_replies
=
(
Redis
Message
*
)
_arena
.
allocate
(
sizeof
(
Redis
Message
)
*
(
reply_count
-
1
));
if
(
_other_replies
==
NULL
)
{
LOG
(
ERROR
)
<<
"Fail to allocate Redis
Reply
["
<<
reply_count
-
1
<<
"]"
;
LOG
(
ERROR
)
<<
"Fail to allocate Redis
Message
["
<<
reply_count
-
1
<<
"]"
;
return
PARSE_ERROR_ABSOLUTELY_WRONG
;
}
for
(
int
i
=
0
;
i
<
reply_count
-
1
;
++
i
)
{
new
(
&
_other_replies
[
i
])
Redis
Reply
;
new
(
&
_other_replies
[
i
])
Redis
Message
;
}
}
for
(
int
i
=
reply_size
();
i
<
reply_count
;
++
i
)
{
...
...
src/brpc/redis.h
View file @
0c96ecef
...
...
@@ -25,7 +25,7 @@
#include "butil/strings/string_piece.h"
#include "butil/arena.h"
#include "brpc/proto_base.pb.h"
#include "brpc/redis_
reply
.h"
#include "brpc/redis_
message
.h"
#include "brpc/parse_result.h"
namespace
brpc
{
...
...
@@ -157,11 +157,11 @@ public:
int
reply_size
()
const
{
return
_nreply
;
}
// Get index-th reply. If index is out-of-bound, nil reply is returned.
const
Redis
Reply
&
reply
(
int
index
)
const
{
const
Redis
Message
&
reply
(
int
index
)
const
{
if
(
index
<
reply_size
())
{
return
(
index
==
0
?
_first_reply
:
_other_replies
[
index
-
1
]);
}
static
Redis
Reply
redis_nil
;
static
Redis
Message
redis_nil
;
return
redis_nil
;
}
...
...
@@ -199,8 +199,8 @@ private:
void
SharedDtor
();
void
SetCachedSize
(
int
size
)
const
;
Redis
Reply
_first_reply
;
Redis
Reply
*
_other_replies
;
Redis
Message
_first_reply
;
Redis
Message
*
_other_replies
;
butil
::
Arena
_arena
;
int
_nreply
;
mutable
int
_cached_size_
;
...
...
@@ -212,8 +212,8 @@ std::ostream& operator<<(std::ostream& os, const RedisResponse&);
class
RedisConnection
{
public
:
virtual
~
RedisConnection
()
{}
virtual
void
OnRedisMessage
(
const
Redis
Reply
&
message
,
Redis
Reply
*
output
,
butil
::
Arena
*
arena
)
=
0
;
virtual
void
OnRedisMessage
(
const
Redis
Message
&
message
,
Redis
Message
*
output
,
butil
::
Arena
*
arena
)
=
0
;
};
class
RedisService
{
...
...
src/brpc/redis_
reply
.cpp
→
src/brpc/redis_
message
.cpp
View file @
0c96ecef
This diff is collapsed.
Click to expand it.
src/brpc/redis_
reply
.h
→
src/brpc/redis_
message
.h
View file @
0c96ecef
This diff is collapsed.
Click to expand it.
test/brpc_redis_unittest.cpp
View file @
0c96ecef
This diff is collapsed.
Click to expand it.
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