mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
For #464, support config origin cluster
This commit is contained in:
parent
55c96192e2
commit
92f2bcd878
3 changed files with 42 additions and 6 deletions
|
@ -365,10 +365,16 @@ vhost cluster.srs.com {
|
||||||
# default: on
|
# default: on
|
||||||
debug_srs_upnode on;
|
debug_srs_upnode on;
|
||||||
|
|
||||||
|
# For origin(mode local) cluster, turn on the cluster.
|
||||||
|
# default: off
|
||||||
|
# TODO: FIXME: Support reload.
|
||||||
|
origin_cluster off;
|
||||||
|
|
||||||
# For origin (mode local) cluster, the co-worker's HTTP APIs.
|
# For origin (mode local) cluster, the co-worker's HTTP APIs.
|
||||||
# This origin will connect to co-workers and communicate with them.
|
# This origin will connect to co-workers and communicate with them.
|
||||||
# please read: https://github.com/ossrs/srs/wiki/v3_EN_OriginCluster
|
# please read: https://github.com/ossrs/srs/wiki/v3_EN_OriginCluster
|
||||||
coworkers 127.0.0.1:9091 127.0.0.1:9092;
|
# TODO: FIXME: Support reload.
|
||||||
|
coworkers 127.0.0.1:9091 127.0.0.1:9092;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1798,8 +1804,9 @@ http_api {
|
||||||
}
|
}
|
||||||
vhost a.origin.cluster.srs.com {
|
vhost a.origin.cluster.srs.com {
|
||||||
cluster {
|
cluster {
|
||||||
mode local;
|
mode local;
|
||||||
coworkers 127.0.0.1:9091;
|
origin_cluster on;
|
||||||
|
coworkers 127.0.0.1:9091;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1809,7 +1816,8 @@ http_api {
|
||||||
}
|
}
|
||||||
vhost b.origin.cluster.srs.com {
|
vhost b.origin.cluster.srs.com {
|
||||||
cluster {
|
cluster {
|
||||||
mode local;
|
mode local;
|
||||||
coworkers 127.0.0.1:9090;
|
origin_cluster on;
|
||||||
|
coworkers 127.0.0.1:9090;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3726,7 +3726,8 @@ srs_error_t SrsConfig::check_normal_config()
|
||||||
} else if (n == "cluster") {
|
} else if (n == "cluster") {
|
||||||
for (int j = 0; j < (int)conf->directives.size(); j++) {
|
for (int j = 0; j < (int)conf->directives.size(); j++) {
|
||||||
string m = conf->at(j)->name;
|
string m = conf->at(j)->name;
|
||||||
if (m != "mode" && m != "origin" && m != "token_traverse" && m != "vhost" && m != "debug_srs_upnode" && m != "coworkers") {
|
if (m != "mode" && m != "origin" && m != "token_traverse" && m != "vhost" && m != "debug_srs_upnode" && m != "coworkers"
|
||||||
|
&& m != "origin_cluster") {
|
||||||
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal vhost.cluster.%s of %s", m.c_str(), vhost->arg0().c_str());
|
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal vhost.cluster.%s of %s", m.c_str(), vhost->arg0().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5157,6 +5158,28 @@ string SrsConfig::get_vhost_edge_transform_vhost(string vhost)
|
||||||
return conf->arg0();
|
return conf->arg0();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SrsConfig::get_vhost_origin_cluster(string vhost)
|
||||||
|
{
|
||||||
|
static bool DEFAULT = false;
|
||||||
|
|
||||||
|
SrsConfDirective* conf = get_vhost(vhost);
|
||||||
|
if (!conf) {
|
||||||
|
return DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
conf = conf->get("cluster");
|
||||||
|
if (!conf) {
|
||||||
|
return DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
conf = conf->get("origin_cluster");
|
||||||
|
if (!conf || conf->arg0().empty()) {
|
||||||
|
return DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||||
|
}
|
||||||
|
|
||||||
vector<string> SrsConfig::get_vhost_coworkers(string vhost)
|
vector<string> SrsConfig::get_vhost_coworkers(string vhost)
|
||||||
{
|
{
|
||||||
vector<string> coworkers;
|
vector<string> coworkers;
|
||||||
|
|
|
@ -939,6 +939,11 @@ public:
|
||||||
* @see https://github.com/ossrs/srs/issues/372
|
* @see https://github.com/ossrs/srs/issues/372
|
||||||
*/
|
*/
|
||||||
virtual std::string get_vhost_edge_transform_vhost(std::string vhost);
|
virtual std::string get_vhost_edge_transform_vhost(std::string vhost);
|
||||||
|
/**
|
||||||
|
* Whether enable the origin cluster.
|
||||||
|
* @see https://github.com/ossrs/srs/wiki/v3_EN_OriginCluster
|
||||||
|
*/
|
||||||
|
virtual bool get_vhost_origin_cluster(std::string vhost);
|
||||||
/**
|
/**
|
||||||
* Get the co-workers of origin cluster.
|
* Get the co-workers of origin cluster.
|
||||||
* @see https://github.com/ossrs/srs/wiki/v3_EN_OriginCluster
|
* @see https://github.com/ossrs/srs/wiki/v3_EN_OriginCluster
|
||||||
|
|
Loading…
Reference in a new issue