Ejemplo n.º 1
0
 public static RadixTree <IService> CreateDefault() =>
 new RadixTree <IService>(() =>
 {
     var randomRoutingStrategy = new RandomRoutingStrategy <IService>();
     return(new ChildContainer <IService>(new DefaultRouting <IService>
                                              (new[] { randomRoutingStrategy }, new FakeRouteConfig())));
 });
Ejemplo n.º 2
0
        private static IServiceCollection AddCondenser(this IServiceCollection self, string agentAddress, int agentPort)
        {
            var config = new CondenserConfiguration
            {
                AgentPort    = agentPort,
                AgentAddress = agentAddress
            };

            self.AddSingleton(config);
            self.AddTransient <Service>();
            self.AddSingleton <Func <IConsulService> >(x => x.GetService <Service>);
            self.AddSingleton <CurrentState>();
            self.AddTransient <IRoutingStrategy <IService>, RandomRoutingStrategy <IService> >();
            self.AddTransient <IRoutingStrategy <IService>, RoundRobinRoutingStrategy <IService> >();
            self.AddSingleton <IDefaultRouting <IService>, DefaultRouting <IService> >();
            self.AddSingleton <Func <string, HttpClient> >(s => new HttpClient());
            Func <ChildContainer <IService> > factory = () =>
            {
                var randomRoutingStrategy = new RandomRoutingStrategy <IService>();
                return(new ChildContainer <IService>(new DefaultRouting <IService>(new[] { randomRoutingStrategy }, null)));
            };

            self.AddSingleton(new RoutingData(new RadixTree <IService>(factory)));
            self.AddSingleton <CustomRouter>();
            self.AddSingleton <RoutingHost>();
            return(self);
        }
Ejemplo n.º 3
0
        public static RoutingData BuildDefault()
        {
            Func <ChildContainer <IService> > factory = () =>
            {
                var randomRoutingStrategy = new RandomRoutingStrategy <IService>();
                return(new ChildContainer <IService>(new DefaultRouting <IService>(new[] { randomRoutingStrategy }, null)));
            };

            return(new RoutingData(new RadixTree <IService>(factory)));
        }
Ejemplo n.º 4
0
        private CustomRouter BuildRouter()
        {
            Func <ChildContainer <IService> > createNode = () =>
            {
                var randomRoutingStrategy = new RandomRoutingStrategy <IService>();
                return(new ChildContainer <IService>(new DefaultRouting <IService>(new[] { randomRoutingStrategy },
                                                                                   null)));
            };
            var data = new RoutingData(new RadixTree <IService>(createNode));

            return(new CustomRouter(null, data));
        }