public static IServiceCollection AddCondenser(this IServiceCollection self, string agentAddress, int agentPort, IHealthConfig health, IRoutingConfig routingConfig, IHttpClientConfig httpClientConfig) { var config = new CondenserConfiguration { AgentPort = agentPort, AgentAddress = agentAddress }; self.AddSingleton(config); self.AddSingleton(health); self.AddSingleton(routingConfig); self.AddSingleton(httpClientConfig); self.AddSingleton <RoutingData>(); self.AddSingleton <IService, HealthRouter>(); self.AddSingleton <IService, RouteSummary>(); self.AddSingleton <IService, TreeRouter>(); self.AddSingleton <IService, ChangeRoutingStrategy>(); self.AddSingleton <IService, ServerStatsRoute>(); self.AddTransient <IRoutingStrategy <IService>, RandomRoutingStrategy <IService> >(); self.AddTransient <IRoutingStrategy <IService>, RoundRobinRoutingStrategy <IService> >(); self.AddSingleton <IDefaultRouting <IService>, DefaultRouting <IService> >(); self.AddTransient <ChildContainer <IService> >(); self.AddSingleton <CurrentState>(); self.AddSingleton <CustomRouter>(); self.AddSingleton <RoutingHost>(); self.AddSingleton <RadixTree <IService> >(); self.AddTransient <Service>(); self.AddSingleton <Func <IConsulService> >(x => x.GetService <Service>); self.AddSingleton <Func <ChildContainer <IService> > >(x => x.GetService <ChildContainer <IService> >); return(self); }
public DefaultRouting(IEnumerable <IRoutingStrategy <T> > strategy, IRoutingConfig config) { var name = (config?.DefaultRouteStrategy ?? RouteStrategy.Random.ToString()); Default = strategy.Single(x => x.Name == name); }
public RoutingManager(IConnectionManager connectionManager, IRoutingConfig config) { this.connectionManager = connectionManager; this.config = config; versionsByPeer = new Dictionary <IAddress, VersionInfo>(); Map = new RoutingMap(connectionManager.Address, config); random = new Random(connectionManager.Address.GetHashCode()); }
private static HackerNode CreateNode(IConnectionConfig connectionConfig, IRoutingConfig routingConfig, string storagePath) { var encryptionManager = new EncryptionManager(((TcpAddress)connectionConfig.LocalAddress).Endpoint, connectionConfig.KeySendCooldown); var connectionManager = new TcpConnectionManager(connectionConfig, routingConfig, encryptionManager); var routingManager = new RoutingManager(connectionManager, routingConfig); var dataManager = new DataManager(LoadStorage(storagePath) ?? new DataStorage(), storagePath, routingManager, encryptionManager); return(new HackerNode(routingManager, connectionManager, dataManager, encryptionManager, routingConfig.DoLogMap)); }
public RouterServerActualizer(IStatisticsProvider statsProvider, ITaskSchedulerFactory taskSchedulerFactory, IRequestSender requestSender, IRoutingConfig routingConfig, IShamanLogger logger) { _statsProvider = statsProvider; _requestSender = requestSender; _routingConfig = routingConfig; _logger = logger; _taskScheduler = taskSchedulerFactory.GetTaskScheduler(); }
public TcpConnectionManager(IConnectionConfig connectionConfig, IRoutingConfig routingConfig, IEncryptionManager encryptionManager) { this.connectionConfig = connectionConfig; this.routingConfig = routingConfig; this.encryptionManager = encryptionManager; connections = new List <TcpConnection>(); connectingSockets = new List <SocketInfo>(); Utility = new TcpUtility(); CreateListener(); }
public RoutingHost(ILoggerFactory logger, CustomRouter router, IRouteStore store, IRouteSource source, IRoutingConfig config) { _router = router; _logger = logger?.CreateLogger <RoutingHost>(); _store = store; _source = source; _config = config; var ignore = WatchLoop(); }
private static TestNode CreateNode(IRoutingConfig routingConfig, List <IAddress> nodes, int id) { var connectionConfig = Substitute.For <IConnectionConfig>(); var address = new TcpAddress(new IPEndPoint(IPAddress.Loopback, 16800 + id)); connectionConfig.LocalAddress.Returns(address); connectionConfig.PreconfiguredNodes.Returns(_ => nodes.Where(n => !Equals(n, address)).ToList()); connectionConfig.ConnectingSocketMaxTTL.Returns(TimeSpan.FromMilliseconds(50)); connectionConfig.ConnectingSocketsToConnectionsMultiplier.Returns(5); nodes.Add(address); var encryptionManager = Substitute.For <IEncryptionManager>(); var encoder = Substitute.For <IMessageEncoder>(); encryptionManager.CreateEncoder(Arg.Any <IConnection>()).Returns(encoder); return(new TestNode(new TcpConnectionManager(connectionConfig, routingConfig, encryptionManager))); }
private static TestNode CreateNode(IRoutingConfig routingConfig, List <IAddress> nodes, int id) { var connectionConfig = Substitute.For <IConnectionConfig>(); var address = new TcpAddress(new IPEndPoint(IPAddress.Loopback, 16800 + id)); connectionConfig.LocalAddress.Returns(address); connectionConfig.PreconfiguredNodes.Returns(_ => nodes.Where(n => !Equals(n, address)).ToList()); nodes.Add(address); connectionConfig.ConnectingSocketMaxTTL.Returns(TimeSpan.FromMilliseconds(50)); connectionConfig.ConnectingSocketsToConnectionsMultiplier.Returns(5); connectionConfig.KeySendCooldown.Returns(TimeSpan.FromMilliseconds(1000)); var encryptionManager = new EncryptionManager(address.Endpoint, connectionConfig.KeySendCooldown); var connectionManager = new TcpConnectionManager(connectionConfig, routingConfig, encryptionManager); var routingManager = new RoutingManager(connectionManager, routingConfig); var dataManager = new DataManager(new DataStorage(), "local", routingManager, encryptionManager); return(new TestNode(routingManager, connectionManager, dataManager, encryptionManager)); }
public RoutingMap(IAddress ownAddress, IRoutingConfig config) { this.config = config; OwnAddress = ownAddress; Links = new List <RoutingMapLink>(); }
public RoutingMap(IAddress ownAddress, IEnumerable <RoutingMapLink> links, IRoutingConfig config) { this.config = config; OwnAddress = ownAddress; Links = new List <RoutingMapLink>(links); }
public RouterClient(IRequestSender requestSender, IShamanLogger logger, IRoutingConfig routingConfig) { _requestSender = requestSender; _logger = logger; _routingConfig = routingConfig; }