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