/// <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"))); }
/// <summary> /// Método de búsqueda por divición rándom /// </summary> /// <param name="customerId">Id del usuario</param> /// <param name="startDate">Fecha de inicio</param> /// <param name="endDate">Fecha de fin</param> /// <returns>Objeto del tipo Json</returns> public JsonResult randomSearch(string customerId, string startDate, string endDate) { var sDate = DateTime.MinValue; var eDate = DateTime.MinValue; if (DateTime.TryParse(startDate, out sDate) && DateTime.TryParse(endDate, out eDate)) { var request = new InvoiceCountRequest(customerId, sDate, eDate); var result = new RandomLogic().GetCustomerInvoicesCount(request); return(Json(result, JsonRequestBehavior.AllowGet)); } else { Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(Json(new { message = "Error" }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// Creates cluster publish subscribe settings from provided configuration with the same layout as `akka.cluster.pub-sub`. /// </summary> /// <param name="config">TBD</param> /// <exception cref="ArgumentException">TBD</exception> /// <returns>TBD</returns> public static DistributedPubSubSettings Create(Config config) { if (config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <DistributedPubSubSettings>(); } 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); } // TODO: This will fail if DistributedPubSub.DefaultConfig() is not inside the fallback chain. // TODO: "gossip-interval" key depends on Config.GetTimeSpan() to return a TimeSpan.Zero default. // TODO: "removed-time-to-live" key depends on Config.GetTimeSpan() to return a TimeSpan.Zero default. // TODO: "max-delta-elements" key depends on Config.GetInt() to return a 0 default. return(new DistributedPubSubSettings( config.GetString("role", null), routingLogic, config.GetTimeSpan("gossip-interval"), config.GetTimeSpan("removed-time-to-live"), config.GetInt("max-delta-elements"), config.GetBoolean("send-to-dead-letters-when-no-subscribers"))); }