mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 03:41:55 +00:00
create the metadata request message
This commit is contained in:
parent
ca3b89aa7d
commit
ab1e62a886
2 changed files with 92 additions and 0 deletions
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue