public static IList <IRequestModule> BuildChain(IClusterClientConfiguration config, IReplicaStorageProvider storageProvider) { var responseClassifier = new ResponseClassifier(); var requestConverter = new RequestConverter(config.Log); var requestSender = new RequestSender(config, storageProvider, responseClassifier, requestConverter, config.Transport); var resultStatusSelector = new ClusterResultStatusSelector(); var modules = new List <IRequestModule>(15 + config.Modules?.Count ?? 0) { new ErrorCatchingModule(), new RequestTransformationModule(config.RequestTransforms), new OperationNameFallbackModule(), new RequestPriorityApplicationModule() }; if (config.Modules != null) { modules.AddRange(config.Modules); } if (config.EnableTracing) { modules.Add(new TracingModule(config.ServiceName)); } modules.Add(new LoggingModule(config.LogRequestDetails, config.LogResultDetails)); modules.Add(new ResponseTransformationModule(config.ResponseTransforms)); modules.Add(new ErrorCatchingModule()); modules.Add(new RequestValidationModule()); modules.Add(new TimeoutValidationModule()); modules.Add(new RequestRetryModule(config.RetryPolicy, config.RetryStrategy)); if (config.AdaptiveThrottling != null) { modules.Add(new AdaptiveThrottlingModule(config.AdaptiveThrottling)); } if (config.ReplicaBudgeting != null) { modules.Add(new ReplicaBudgetingModule(config.ReplicaBudgeting)); } modules.Add(new AbsoluteUrlSenderModule(config.Transport, responseClassifier, config.ResponseCriteria, resultStatusSelector)); modules.Add(new RequestExecutionModule(config.ClusterProvider, config.ReplicaOrdering, config.ResponseSelector, storageProvider, requestSender, resultStatusSelector)); return(modules); }
public static IList <IRequestModule> BuildChain(IClusterClientConfiguration config, IReplicaStorageProvider storageProvider) { var responseClassifier = new ResponseClassifier(); var requestConverter = new RequestConverter(config.Log, config.DeduplicateRequestUrl); var requestSender = new RequestSender(config, storageProvider, responseClassifier, requestConverter); var resultStatusSelector = new ClusterResultStatusSelector(); // ReSharper disable once UseObjectOrCollectionInitializer var modules = new List <IRequestModule>(12 + config.Modules?.Sum(x => x.Value.Count) ?? 0); var addedModules = new HashSet <Type>(); AddModule(new LeakPreventionModule()); AddModule(new GlobalErrorCatchingModule()); AddModule(new RequestTransformationModule(config.RequestTransforms)); AddModule(new AuxiliaryHeadersModule()); // -->> user-defined modules by default inserted here <<-- // AddModule(new LoggingModule(config.Logging.LogRequestDetails, config.Logging.LogResultDetails, config.TargetServiceName)); AddModule(new ResponseTransformationModule(config.ResponseTransforms)); AddModule(new ErrorCatchingModule()); AddModule(new RequestValidationModule()); AddModule(new TimeoutValidationModule()); AddModule(new RequestRetryModule(config.RetryPolicy, config.RetryStrategyEx)); // -->> adaptive throttling module <<-- // AddModule(new AbsoluteUrlSenderModule(responseClassifier, config.ResponseCriteria, resultStatusSelector)); // -->> replica budgeting module <<-- // // -->> service-mesh module is injected before RequestExecutionModule <<-- // AddModule( new RequestExecutionModule( config.ResponseSelector, storageProvider, requestSender, resultStatusSelector)); return(modules); void AddModules(IEnumerable <IRequestModule> modulesRange) { if (modulesRange == null) { return; } foreach (var module in modulesRange) { AddModule(module); } } void AddModule(IRequestModule module) { if (config.ModulesToRemove.Contains(module.GetType())) { return; } var moduleType = module.GetType(); var isNewModule = addedModules.Add(moduleType); if (!isNewModule || config.Modules == null) { modules.Add(module); return; } var relatedModules = config.Modules.TryGetValue(moduleType, out var v) ? v : null; AddModules(relatedModules?.Before); modules.Add(module); AddModules(relatedModules?.After); } }
public void SetUp() { selector = new ClusterResultStatusSelector(); }
public void TestSetup() { selector = new ClusterResultStatusSelector(); }