public override Deploy ParseConfig(string key, Config config)
{
var deploy = base.ParseConfig(key, config);
if (deploy == null) return null;
if (deploy.Config.GetBoolean("cluster.enabled"))
{
if(deploy.Scope != Deploy.NoScopeGiven)
throw new ConfigurationException(string.Format("Cluster deployment can't be combined with scope [{0}]", deploy.Scope));
if(deploy.RouterConfig is RemoteRouterConfig)
throw new ConfigurationException(string.Format("Cluster deployment can't be combined with [{0}]", deploy.Config));
if (deploy.RouterConfig is Pool)
{
return
deploy.WithScope(scope: ClusterScope.Instance)
.WithRouterConfig(new ClusterRouterPool(deploy.RouterConfig as Pool,
ClusterRouterPoolSettings.FromConfig(deploy.Config)));
}
else if (deploy.RouterConfig is Group)
{
return
deploy.WithScope(scope: ClusterScope.Instance)
.WithRouterConfig(new ClusterRouterGroup(deploy.RouterConfig as Group,
ClusterRouterGroupSettings.FromConfig(deploy.Config)));
}
else
{
throw new ArgumentException(string.Format("Cluster-aware router can only wrap Pool or Group, got [{0}]", deploy.RouterConfig.GetType()));
}
}
else
{
return deploy;
}
}
}