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-09-22 14:33:17 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ab1e62a8860cc2891a39587e32494821dae87d2c
ab1e62a8
1 parent
ca3b89aa
create the metadata request message
显示空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
92 行增加
和
0 行删除
trunk/src/protocol/srs_kafka_stack.cpp
trunk/src/protocol/srs_kafka_stack.hpp
trunk/src/protocol/srs_kafka_stack.cpp
查看文件 @
ab1e62a
...
...
@@ -105,6 +105,46 @@ int SrsKafkaRequestHeader::total_size()
return
4
+
size
;
}
bool
SrsKafkaRequestHeader
::
is_producer_request
()
{
return
api_key
==
SrsKafkaApiKeyProduceRequest
;
}
bool
SrsKafkaRequestHeader
::
is_fetch_request
()
{
return
api_key
==
SrsKafkaApiKeyFetchRequest
;
}
bool
SrsKafkaRequestHeader
::
is_offset_request
()
{
return
api_key
==
SrsKafkaApiKeyOffsetRequest
;
}
bool
SrsKafkaRequestHeader
::
is_metadata_request
()
{
return
api_key
==
SrsKafkaApiKeyMetadataRequest
;
}
bool
SrsKafkaRequestHeader
::
is_offset_commit_request
()
{
return
api_key
==
SrsKafkaApiKeyOffsetCommitRequest
;
}
bool
SrsKafkaRequestHeader
::
is_offset_fetch_request
()
{
return
api_key
==
SrsKafkaApiKeyOffsetFetchRequest
;
}
bool
SrsKafkaRequestHeader
::
is_consumer_metadata_request
()
{
return
api_key
==
SrsKafkaApiKeyConsumerMetadataRequest
;
}
void
SrsKafkaRequestHeader
::
set_api_key
(
SrsKafkaApiKey
key
)
{
api_key
=
(
int16_t
)
key
;
}
SrsKafkaResponse
::
SrsKafkaResponse
()
{
correlation_id
=
0
;
...
...
@@ -145,3 +185,12 @@ SrsKafkaMessageSet::~SrsKafkaMessageSet()
messages
.
clear
();
}
SrsKafkaTopicMetadataRequest
::
SrsKafkaTopicMetadataRequest
()
{
header
.
set_api_key
(
SrsKafkaApiKeyMetadataRequest
);
}
SrsKafkaTopicMetadataRequest
::~
SrsKafkaTopicMetadataRequest
()
{
}
...
...
trunk/src/protocol/srs_kafka_stack.hpp
查看文件 @
ab1e62a
...
...
@@ -31,6 +31,19 @@
#include <vector>
// https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol#AGuideToTheKafkaProtocol-ApiKeys
enum
SrsKafkaApiKey
{
SrsKafkaApiKeyProduceRequest
=
0
,
SrsKafkaApiKeyFetchRequest
=
1
,
SrsKafkaApiKeyOffsetRequest
=
2
,
SrsKafkaApiKeyMetadataRequest
=
3
,
/* Non-user facing control APIs 4-7 */
SrsKafkaApiKeyOffsetCommitRequest
=
8
,
SrsKafkaApiKeyOffsetFetchRequest
=
9
,
SrsKafkaApiKeyConsumerMetadataRequest
=
10
,
};
/**
* These types consist of a signed integer giving a length N followed by N bytes of content.
* A length of -1 indicates null. string uses an int16 for its size, and bytes uses an int32.
...
...
@@ -74,6 +87,11 @@ public:
* int32 size containing the length N followed by N repetitions of the structure which can
* itself be made up of other primitive types. In the BNF grammars below we will show an
* array of a structure foo as [foo].
*
* Usage:
* SrsKafkaArray<SrsKafkaBytes> body;
* body.append(new SrsKafkaBytes());
*
* @see https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol#AGuideToTheKafkaProtocol-Requests
*/
template
<
typename
T
>
...
...
@@ -96,6 +114,12 @@ public:
}
elems
.
clear
();
}
public
:
virtual
void
append
(
T
*
elem
)
{
length
++
;
elems
.
push_back
(
elem
);
}
};
/**
...
...
@@ -161,6 +185,20 @@ public:
* @remark total_size = 4 + header_size + message_size.
*/
virtual
int
total_size
();
public
:
/**
* the api key enumeration.
* @see https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol#AGuideToTheKafkaProtocol-ApiKeys
*/
virtual
bool
is_producer_request
();
virtual
bool
is_fetch_request
();
virtual
bool
is_offset_request
();
virtual
bool
is_metadata_request
();
virtual
bool
is_offset_commit_request
();
virtual
bool
is_offset_fetch_request
();
virtual
bool
is_consumer_metadata_request
();
// set the api key.
virtual
void
set_api_key
(
SrsKafkaApiKey
key
);
};
/**
...
...
@@ -262,7 +300,12 @@ public:
*/
class
SrsKafkaTopicMetadataRequest
{
private
:
SrsKafkaRequestHeader
header
;
SrsKafkaArray
<
SrsKafkaString
>
request
;
public
:
SrsKafkaTopicMetadataRequest
();
virtual
~
SrsKafkaTopicMetadataRequest
();
};
#endif
...
...
请
注册
或
登录
后发表评论