Ejemplo n.º 1
0
        public static async Task <IEnhancedOrgService> GetSelfBalancingService(ServiceParams parameters,
                                                                               IReadOnlyCollection <IServicePool <IOrganizationService> > pools, RouterRules rules = null)
        {
            parameters.Require(nameof(parameters));
            pools.Require(nameof(pools));

            if (AutoSetMaxPerformanceParams)
            {
                parameters.AutoSetMaxPerformanceParams();
            }

            var routingService = new RoutingService <IOrganizationService>();

            foreach (var pool in pools)
            {
                routingService.AddNode(pool);
            }

            if (rules != null)
            {
                routingService.DefineRules(rules);
            }

            await routingService.StartRouter();

            var routingPool = new RoutingPool <IOrganizationService>(routingService);

            return(new EnhancedServiceFactory <IEnhancedOrgService, Services.Enhanced.EnhancedOrgService>(parameters)
                   .CreateService(routingPool));
        }
Ejemplo n.º 2
0
        public static IEnhancedServicePool <ICachingOrgService> GetCachingPool(ServiceParams serviceParams)
        {
            serviceParams.Require(nameof(serviceParams));

            if (AutoSetMaxPerformanceParams)
            {
                serviceParams.AutoSetMaxPerformanceParams();
            }

            var factory = new EnhancedServiceFactory <ICachingOrgService, CachingOrgService>(serviceParams);

            return(new EnhancedServicePool <ICachingOrgService, CachingOrgService>(factory, serviceParams.PoolParams));
        }
Ejemplo n.º 3
0
        public static ICachingOrgService GetCachingPoolingService(ServiceParams serviceParams)
        {
            serviceParams.Require(nameof(serviceParams));

            if (AutoSetMaxPerformanceParams)
            {
                serviceParams.AutoSetMaxPerformanceParams();
            }

            var pool    = new DefaultServicePool(serviceParams);
            var factory = new EnhancedServiceFactory <ICachingOrgService, CachingOrgService>(serviceParams);

            return(factory.CreateService(pool));
        }
Ejemplo n.º 4
0
        public static IEnhancedOrgService GetPoolingService(ServiceParams serviceParams)
        {
            serviceParams.Require(nameof(serviceParams));

            if (AutoSetMaxPerformanceParams)
            {
                serviceParams.AutoSetMaxPerformanceParams();
            }

            var pool    = new DefaultServicePool(serviceParams);
            var factory = new DefaultEnhancedFactory(serviceParams);

            return(factory.CreateService(pool));
        }