Exemple #1
0
        private static ServiceParams BuildBaseParams(string connectionString, int?poolSize = null,
                                                     PoolParams poolParams       = null, ConnectionParams connectionParams = null,
                                                     CachingParams cachingParams = null)
        {
            var parameters =
                new ServiceParams
            {
                ConnectionParams = connectionParams ?? new ConnectionParams {
                    ConnectionString = connectionString
                },
                PoolParams = poolParams ?? (poolSize == null ? null : new PoolParams {
                    PoolSize = poolSize
                })
            };

            if (cachingParams != null)
            {
                parameters.IsCachingEnabled = true;
                parameters.CachingParams    = cachingParams;
            }

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

            return(parameters);
        }
Exemple #2
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));
        }
Exemple #3
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));
        }
Exemple #4
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));
        }
Exemple #5
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));
        }