/// <summary>
/// Creates cluster publish subscribe settings from provided configuration with the same layout as `akka.cluster.pub-sub`.
/// </summary>
public static DistributedPubSubSettings Create(Config config)
{
RoutingLogic routingLogic = null;
var routingLogicName = config.GetString("routing-logic");
switch (routingLogicName)
{
case "random":
routingLogic = new RandomLogic();
break;
case "round-robin":
routingLogic = new RoundRobinRoutingLogic();
break;
case "broadcast":
routingLogic = new BroadcastRoutingLogic();
break;
case "consistent-hashing":
throw new ArgumentException("Consistent hashing routing logic cannot be used by the pub-sub mediator");
default:
throw new ArgumentException("Unknown routing logic is tried to be applied to the pub-sub mediator: " +
routingLogicName);
}
return new DistributedPubSubSettings(
config.GetString("role"),
routingLogic,
config.GetTimeSpan("gossip-interval"),
config.GetTimeSpan("removed-time-to-live"),
config.GetInt("max-delta-elements"));
}