Example #1
0
 /// <summary>
 /// Registers all routes discovered by specified <see cref="IRoutingStrategy"/> in the RouteTable.
 /// </summary>
 /// <param name="strategy">A strategy that provides list of routes.</param>
 /// <param name="table">A table of DotVVM routes by specified name.</param>
 public static void AutoDiscoverRoutes(this DotvvmRouteTable table, IRoutingStrategy strategy)
 {
     foreach (var route in strategy.GetRoutes())
     {
         table.Add(route.RouteName, route);
     }
 }
Example #2
0
 /// <summary>
 /// Registers all routes discovered by specified <see cref="IRoutingStrategy"/> in the RouteTable.
 /// </summary>
 /// <param name="strategy">A strategy that provides list of routes.</param>
 public static void AutoDiscoverRoutes(this DotvvmRouteTable table, IRoutingStrategy strategy)
 {
     foreach (var route in strategy.GetRoutes())
     {
         table.Add(route.RouteName, route);
     }
 }
Example #3
0
 private void ReplaceStrategy(Node <IService> node, IRoutingStrategy <IService> strategy)
 {
     foreach (var child in node.ChildrenNodes)
     {
         child.Item2.Services.SetRoutingStrategy(strategy, _externalServicesOnly);
         ReplaceStrategy(child.Item2, strategy);
     }
 }
Example #4
0
 internal ServiceWatcher(string serviceName, HttpClient client, IRoutingStrategy <InformationServiceSet> routingStrategy, ILogger logger)
 {
     _serviceName     = serviceName;
     _logger          = logger;
     _routingStrategy = routingStrategy;
     _url             = $"{HttpUtils.ServiceHealthUrl}{serviceName}?passing&index=";
     var ignore = WatcherLoop(client);
 }
Example #5
0
 private void ReplaceStrategy(Node <IService> node, IRoutingStrategy <IService> strategy)
 {
     foreach (var child in node.ChildrenNodes)
     {
         child.Value.Services.SetRoutingStrategy(strategy);
         ReplaceStrategy(child.Value, strategy);
     }
 }
 protected internal Router(RouterSpecification specification, IRoutingStrategy routingStrategy)
 {
     for (int i = 0; i < specification.PoolSize; i++)
     {
         ChildActorFor(specification.RouterDefinition, specification.RouterProtocol);
     }
     this.routees         = Routee.ForAll(LifeCycle.Environment.Children);
     this.routingStrategy = routingStrategy;
 }
        public ServiceWatcher(string serviceName,
                              HttpClient client, CancellationToken cancel,
                              IRoutingStrategy <InformationServiceSet> routingStrategy)
        {
            _routingStrategy = routingStrategy;
            string lookupUrl = $"{HttpUtils.ServiceHealthUrl}{serviceName}";

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            _watcher = new BlockingWatcher <List <InformationServiceSet> >(lookupUrl, client, cancel);
            _watcher.WatchLoop();
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
        }
Example #8
0
 internal ServiceWatcher(string serviceName, HttpClient client, IRoutingStrategy <InformationServiceSet> routingStrategy, ILogger logger, bool useNearest)
 {
     _isNearest       = useNearest;
     _serviceName     = serviceName;
     _logger          = logger;
     _routingStrategy = routingStrategy;
     _url             = $"{HttpUtils.ServiceHealthUrl}{serviceName}?passing=true";
     if (_isNearest)
     {
         _url += "&near=_agent";
     }
     _url += "&index=";
     _logger?.LogInformation("Started watching service with name {serviceName}", _serviceName);
     var ignore = WatcherLoop(client);
 }
Example #9
0
 public void SetDefault(IRoutingStrategy <T> strategy) => Interlocked.Exchange(ref _default, strategy);
Example #10
0
 public void SetDefault(IRoutingStrategy <T> strategy)
 {
     Default = strategy;
 }
Example #11
0
 public void SetRoutingStrategy(IRoutingStrategy <T> routingStrategy)
 {
     _routingStrategy = routingStrategy;
 }
Example #12
0
 public ChildContainer(IDefaultRouting <T> defaultStrategy)
 {
     _routingStrategy = defaultStrategy.Default;
 }
Example #13
0
 public ServicesMonitorWatcher(string serviceName, IRoutingStrategy <ServiceInfo> routingStrategy, ConsulClient client, ILogger logger)
     : base(serviceName, client, logger, WatcherType.Services)
 {
     _routingStrategy = routingStrategy;
 }
Example #14
0
        /// <summary>
        /// Adds collection of routes defined by <see cref="IRoutingStrategy"/> to RouteTable.
        /// </summary>
        /// <param name="table"></param>
        /// <param name="strategy">Object that provides list of routes.</param>
        public static void RegisterRoutingStrategy(this DotvvmRouteTable table, IRoutingStrategy strategy)
        {
            var routes = new List <RouteInfo>(strategy.GetRoutes() ?? new List <RouteInfo>());

            routes.ForEach(r => table.Add(r.RouteName, r.RouteUrl, r.VirtualPath, r.DefaultObject));
        }