Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2015-10-15 18:08:17 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8a4ec49064fe6a5d7c1f39c60f97555852e535b2
8a4ec490
1 parent
8974fe29
add graph comments for size of request and response.
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
77 行增加
和
14 行删除
trunk/src/protocol/srs_kafka_stack.cpp
trunk/src/protocol/srs_kafka_stack.hpp
trunk/src/protocol/srs_kafka_stack.cpp
查看文件 @
8a4ec49
...
...
@@ -150,13 +150,29 @@ void SrsKafkaRequestHeader::set_api_key(SrsKafkaApiKey key)
api_key
=
(
int16_t
)
key
;
}
SrsKafkaResponse
::
SrsKafkaResponse
()
SrsKafkaResponse
Header
::
SrsKafkaResponseHeader
()
{
size
=
0
;
correlation_id
=
0
;
}
SrsKafkaResponse
::~
SrsKafkaResponse
()
SrsKafkaResponseHeader
::~
SrsKafkaResponseHeader
()
{
}
int
SrsKafkaResponseHeader
::
header_size
()
{
return
4
;
}
int
SrsKafkaResponseHeader
::
message_size
()
{
return
size
-
header_size
();
}
int
SrsKafkaResponseHeader
::
total_size
()
{
return
4
+
size
;
}
SrsKafkaMessage
::
SrsKafkaMessage
()
...
...
trunk/src/protocol/srs_kafka_stack.hpp
查看文件 @
8a4ec49
...
...
@@ -179,18 +179,24 @@ public:
virtual
~
SrsKafkaRequestHeader
();
public
:
/**
* the size of header, exclude the 4bytes size.
* @remark total_size = 4 + header_size + message_size.
* the layout of request:
* +-----------+----------------------------------+
* | 4B size | [size] bytes |
* +-----------+------------+---------------------+
* | 4B size | header | message |
* +-----------+------------+---------------------+
* | total size = 4 + header + message |
* +----------------------------------------------+
* where the header is specifies this request header without the start 4B size.
* @remark size = 4 + header + message.
*/
virtual
int
header_size
();
/**
* the size of message, the bytes left after the header.
* @remark total_size = 4 + header_size + message_size.
*/
virtual
int
message_size
();
/**
* the total size of the request, 4bytes + size of header and message.
* @remark total_size = 4 + header_size + message_size.
* the total size of the request, includes the 4B size.
*/
virtual
int
total_size
();
public
:
...
...
@@ -210,21 +216,53 @@ public:
};
/**
* the common kafka response.
* The response will always match the paired request (e.g. we will
* the header of response, include the size of response.
* The response will always match the paired request (e.g. we will
* send a MetadataResponse in return to a MetadataRequest).
* @see https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol#AGuideToTheKafkaProtocol-Responses
*/
class
SrsKafkaResponse
class
SrsKafkaResponse
Header
{
pr
otected
:
pr
ivate
:
/**
* The server passes back whatever integer the client supplied as the correlation in the request.
* The MessageSize field gives the size of the subsequent request or response
* message in bytes. The client can read requests by first reading this 4 byte
* size as an integer N, and then reading and parsing the subsequent N bytes
* of the request.
*/
int32_t
size
;
private
:
/**
* This is a user-supplied integer. It will be passed back in
* the response by the server, unmodified. It is useful for matching
* request and response between the client and server.
*/
int32_t
correlation_id
;
public
:
SrsKafkaResponse
();
virtual
~
SrsKafkaResponse
();
SrsKafkaResponseHeader
();
virtual
~
SrsKafkaResponseHeader
();
public
:
/**
* the layout of response:
* +-----------+----------------------------------+
* | 4B size | [size] bytes |
* +-----------+------------+---------------------+
* | 4B size | 4B header | message |
* +-----------+------------+---------------------+
* | total size = 4 + 4 + message |
* +----------------------------------------------+
* where the header is specifies this request header without the start 4B size.
* @remark size = 4 + 4 + message.
*/
virtual
int
header_size
();
/**
* the size of message, the bytes left after the header.
*/
virtual
int
message_size
();
/**
* the total size of the request, includes the 4B size.
*/
virtual
int
total_size
();
};
/**
...
...
@@ -316,6 +354,15 @@ public:
virtual
~
SrsKafkaTopicMetadataRequest
();
};
class
SrsKafkaTopicMetadataResponse
{
private
:
SrsKafkaRequestHeader
header
;
public
:
SrsKafkaTopicMetadataResponse
();
virtual
~
SrsKafkaTopicMetadataResponse
();
};
/**
* the kafka protocol stack, use to send and recv kakfa messages.
*/
...
...
请
注册
或
登录
后发表评论