mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Support circuit breaker. 4.0.103
This commit is contained in:
parent
46c980c70a
commit
92fc0af8f4
13 changed files with 434 additions and 9 deletions
|
@ -3608,6 +3608,7 @@ srs_error_t SrsConfig::check_normal_config()
|
|||
&& n != "ff_log_level" && n != "grace_final_wait" && n != "force_grace_quit"
|
||||
&& n != "grace_start_wait" && n != "empty_ip_ok" && n != "disable_daemon_for_docker"
|
||||
&& n != "inotify_auto_reload" && n != "auto_reload_for_docker" && n != "tcmalloc_release_rate"
|
||||
&& n != "circuit_breaker"
|
||||
) {
|
||||
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal directive %s", n.c_str());
|
||||
}
|
||||
|
@ -4321,6 +4322,125 @@ double SrsConfig::tcmalloc_release_rate()
|
|||
return trr;
|
||||
}
|
||||
|
||||
bool SrsConfig::get_circuit_breaker()
|
||||
{
|
||||
static bool DEFAULT = true;
|
||||
|
||||
SrsConfDirective* conf = root->get("circuit_breaker");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("enabled");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return SRS_CONF_PERFER_TRUE(conf->arg0());
|
||||
}
|
||||
|
||||
int SrsConfig::get_high_threshold()
|
||||
{
|
||||
static int DEFAULT = 90;
|
||||
|
||||
SrsConfDirective* conf = root->get("circuit_breaker");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("high_threshold");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return ::atoi(conf->arg0().c_str());
|
||||
}
|
||||
|
||||
int SrsConfig::get_high_pulse()
|
||||
{
|
||||
static int DEFAULT = 2;
|
||||
|
||||
SrsConfDirective* conf = root->get("circuit_breaker");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("high_pulse");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return ::atoi(conf->arg0().c_str());
|
||||
}
|
||||
|
||||
int SrsConfig::get_critical_threshold()
|
||||
{
|
||||
static int DEFAULT = 95;
|
||||
|
||||
SrsConfDirective* conf = root->get("circuit_breaker");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("critical_threshold");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return ::atoi(conf->arg0().c_str());
|
||||
}
|
||||
|
||||
int SrsConfig::get_critical_pulse()
|
||||
{
|
||||
static int DEFAULT = 1;
|
||||
|
||||
SrsConfDirective* conf = root->get("circuit_breaker");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("critical_pulse");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return ::atoi(conf->arg0().c_str());
|
||||
}
|
||||
|
||||
int SrsConfig::get_dying_threshold()
|
||||
{
|
||||
static int DEFAULT = 99;
|
||||
|
||||
SrsConfDirective* conf = root->get("circuit_breaker");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("dying_threshold");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return ::atoi(conf->arg0().c_str());
|
||||
}
|
||||
|
||||
int SrsConfig::get_dying_pulse()
|
||||
{
|
||||
static int DEFAULT = 5;
|
||||
|
||||
SrsConfDirective* conf = root->get("circuit_breaker");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("dying_pulse");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return ::atoi(conf->arg0().c_str());
|
||||
}
|
||||
|
||||
vector<SrsConfDirective*> SrsConfig::get_stream_casters()
|
||||
{
|
||||
srs_assert(root);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue