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)); }
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)); }
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)); }
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)); }