mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 03:41:55 +00:00
support without kafka
This commit is contained in:
parent
abb5c5ad31
commit
9a9483e7d5
6 changed files with 38 additions and 1 deletions
|
@ -28,6 +28,8 @@
|
|||
#include <srs_app_config.hpp>
|
||||
#include <srs_app_async_call.hpp>
|
||||
|
||||
#ifdef SRS_AUTO_KAFKA
|
||||
|
||||
SrsKafkaProducer::SrsKafkaProducer()
|
||||
{
|
||||
worker = new SrsAsyncCallWorker();
|
||||
|
@ -66,3 +68,5 @@ void SrsKafkaProducer::stop()
|
|||
worker->stop();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -31,6 +31,11 @@
|
|||
|
||||
class SrsAsyncCallWorker;
|
||||
|
||||
#ifdef SRS_AUTO_KAFKA
|
||||
|
||||
/**
|
||||
* the kafka producer used to save log to kafka cluster.
|
||||
*/
|
||||
class SrsKafkaProducer
|
||||
{
|
||||
private:
|
||||
|
@ -45,3 +50,6 @@ public:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -509,7 +509,9 @@ SrsServer::SrsServer()
|
|||
#ifdef SRS_AUTO_INGEST
|
||||
ingester = NULL;
|
||||
#endif
|
||||
#ifdef SRS_AUTO_KAFKA
|
||||
kafka = new SrsKafkaProducer();
|
||||
#endif
|
||||
}
|
||||
|
||||
SrsServer::~SrsServer()
|
||||
|
@ -539,7 +541,9 @@ void SrsServer::destroy()
|
|||
srs_freep(ingester);
|
||||
#endif
|
||||
|
||||
#ifdef SRS_AUTO_KAFKA
|
||||
srs_freep(kafka);
|
||||
#endif
|
||||
|
||||
if (pid_fd > 0) {
|
||||
::close(pid_fd);
|
||||
|
@ -565,7 +569,9 @@ void SrsServer::dispose()
|
|||
ingester->dispose();
|
||||
#endif
|
||||
|
||||
#ifdef SRS_AUTO_KAFKA
|
||||
kafka->stop();
|
||||
#endif
|
||||
|
||||
SrsSource::dispose_all();
|
||||
|
||||
|
@ -874,12 +880,19 @@ int SrsServer::start_kafka()
|
|||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
#ifdef SRS_AUTO_KAFKA
|
||||
if ((ret = kafka->initialize()) != ERROR_SUCCESS) {
|
||||
srs_error("initialize the kafka producer failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return kafka->start();
|
||||
if ((ret = kafka->start()) != ERROR_SUCCESS) {
|
||||
srs_error("start kafka failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SrsServer::cycle()
|
||||
|
|
|
@ -55,7 +55,9 @@ class SrsTcpListener;
|
|||
#ifdef SRS_AUTO_STREAM_CASTER
|
||||
class SrsAppCasterFlv;
|
||||
#endif
|
||||
#ifdef SRS_AUTO_KAFKA
|
||||
class SrsKafkaProducer;
|
||||
#endif
|
||||
|
||||
// listener type for server to identify the connection,
|
||||
// that is, use different type to process the connection.
|
||||
|
@ -248,7 +250,9 @@ private:
|
|||
#ifdef SRS_AUTO_INGEST
|
||||
SrsIngester* ingester;
|
||||
#endif
|
||||
#ifdef SRS_AUTO_KAFKA
|
||||
SrsKafkaProducer* kafka;
|
||||
#endif
|
||||
private:
|
||||
/**
|
||||
* the pid file fd, lock the file write when server is running.
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
#ifdef SRS_AUTO_KAFKA
|
||||
|
||||
SrsKafkaString::SrsKafkaString()
|
||||
{
|
||||
size = -1;
|
||||
|
@ -194,3 +196,5 @@ SrsKafkaTopicMetadataRequest::~SrsKafkaTopicMetadataRequest()
|
|||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#ifdef SRS_AUTO_KAFKA
|
||||
|
||||
// https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol#AGuideToTheKafkaProtocol-ApiKeys
|
||||
enum SrsKafkaApiKey
|
||||
{
|
||||
|
@ -310,3 +312,5 @@ public:
|
|||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue