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
bd7522b6
Commit
bd7522b6
authored
Nov 21, 2019
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redis_server_protocol: improve user comment
parent
0c96ecef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
+21
-7
redis_protocol.cpp
src/brpc/policy/redis_protocol.cpp
+5
-1
redis.h
src/brpc/redis.h
+15
-5
server.h
src/brpc/server.h
+1
-1
No files found.
src/brpc/policy/redis_protocol.cpp
View file @
bd7522b6
...
...
@@ -115,9 +115,13 @@ ParseResult ParseRedisMessage(butil::IOBuf* source, Socket* socket,
}
const
Server
*
server
=
static_cast
<
const
Server
*>
(
arg
);
if
(
server
)
{
RedisService
*
rs
=
server
->
options
().
redis_service
;
if
(
!
rs
)
{
return
MakeParseError
(
PARSE_ERROR_TRY_OTHERS
);
}
ServerContext
*
ctx
=
static_cast
<
ServerContext
*>
(
socket
->
parsing_context
());
if
(
ctx
==
NULL
)
{
RedisConnection
*
conn
=
server
->
options
().
redis_service
->
NewConnection
();
RedisConnection
*
conn
=
rs
->
NewConnection
();
if
(
!
conn
)
{
LOG
(
ERROR
)
<<
"Fail to new redis connection from redis service"
;
return
MakeParseError
(
PARSE_ERROR_TRY_OTHERS
);
...
...
src/brpc/redis.h
View file @
bd7522b6
...
...
@@ -208,7 +208,22 @@ private:
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
RedisRequest
&
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
RedisResponse
&
);
class
RedisConnection
;
// Implement this class and assign an instance to ServerOption.redis_service
// to enable redis support. The return type of NewConnection(), which is
// RedisConnection, should also be implemented by users.
class
RedisService
{
public
:
virtual
~
RedisService
()
{}
virtual
RedisConnection
*
NewConnection
()
=
0
;
};
// Implement this class and make RedisServiceImpl::NewConnection return the
// implemented class. Notice that one TCP connection corresponds to one RedisConnection
// instance, and for the same TCP connection, OnRedisMessage is called sequentially.
// But OnRedisMessage are called concurrently between different TCP connections.
// Read src/brpc/redis_message.h to get the idea how to read and write RedisMessage.
class
RedisConnection
{
public
:
virtual
~
RedisConnection
()
{}
...
...
@@ -216,11 +231,6 @@ public:
RedisMessage
*
output
,
butil
::
Arena
*
arena
)
=
0
;
};
class
RedisService
{
public
:
virtual
~
RedisService
()
{}
virtual
RedisConnection
*
NewConnection
()
=
0
;
};
}
// namespace brpc
...
...
src/brpc/server.h
View file @
bd7522b6
...
...
@@ -237,7 +237,7 @@ struct ServerOptions {
// Customize parameters of HTTP2, defined in http2.h
H2Settings
h2_settings
;
// For processing Redis conne
ection
s.
// For processing Redis conne
ctions. Read src/brpc/redis.h for detail
s.
// Default: NULL (disabled)
RedisService
*
redis_service
;
...
...
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