Skip to content

Commit

Permalink
For #464, support config origin cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Feb 16, 2018
1 parent 55c9619 commit 92f2bcd
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
18 changes: 13 additions & 5 deletions trunk/conf/full.conf
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,16 @@ vhost cluster.srs.com {
# default: 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.
# This origin will connect to co-workers and communicate with them.
# 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;
}
}

Expand Down Expand Up @@ -1798,8 +1804,9 @@ http_api {
}
vhost a.origin.cluster.srs.com {
cluster {
mode local;
coworkers 127.0.0.1:9091;
mode local;
origin_cluster on;
coworkers 127.0.0.1:9091;
}
}

Expand All @@ -1809,7 +1816,8 @@ http_api {
}
vhost b.origin.cluster.srs.com {
cluster {
mode local;
coworkers 127.0.0.1:9090;
mode local;
origin_cluster on;
coworkers 127.0.0.1:9090;
}
}
25 changes: 24 additions & 1 deletion trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3726,7 +3726,8 @@ srs_error_t SrsConfig::check_normal_config()
} else if (n == "cluster") {
for (int j = 0; j < (int)conf->directives.size(); j++) {
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());
}
}
Expand Down Expand Up @@ -5157,6 +5158,28 @@ string SrsConfig::get_vhost_edge_transform_vhost(string vhost)
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> coworkers;
Expand Down
5 changes: 5 additions & 0 deletions trunk/src/app/srs_app_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,11 @@ class SrsConfig
* @see https://github.com/ossrs/srs/issues/372
*/
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.
* @see https://github.com/ossrs/srs/wiki/v3_EN_OriginCluster
Expand Down

0 comments on commit 92f2bcd

Please sign in to comment.