예제 #1
0
 /// <summary>
 /// <para>Adds given <paramref name="module"/> to configuration's <see cref="IClusterClientConfiguration.Modules"/> collection.</para>
 /// <para><paramref name="module"/> will be inserted into request module chain once near <paramref name="relatedModule"/>.</para>
 /// </summary>
 /// <param name="relatedModule">A module near which <paramref name="module"/> will be inserted.</param>
 /// <param name="module">A module to insert into request pipeline.</param>
 /// <param name="configuration">A configuration instance.</param>
 /// <param name="position">A relative position of <paramref name="module"/> from <paramref name="relatedModule"/>. This parameter is optional and has default value <see cref="ModulePosition.Before"/>.</param>
 public static void AddRequestModule(
     this IClusterClientConfiguration configuration,
     IRequestModule module,
     RequestModule relatedModule = RequestModule.Logging,
     ModulePosition position     = ModulePosition.Before)
 {
     configuration.AddRequestModule(module, RequestModulesMapping.GetModuleType(relatedModule), position);
 }
예제 #2
0
        public void Members_of_RequestModules_should_be_ordered_in_pipeline_order()
        {
            var configuration = new ClusterClientConfiguration(new SilentLog());

            configuration.TargetServiceName = string.Empty;

            configuration.SetupAdaptiveThrottling();
            configuration.SetupReplicaBudgeting();
            configuration.SetupHttpMethodValidation();
            configuration.SetupThreadPoolLimitsTuning();

            var chain = RequestModuleChainBuilder.BuildChain(configuration, new PerInstanceReplicaStorageProvider());

            var values = (RequestModule[])Enum.GetValues(typeof(RequestModule));

            values.Should().HaveCount(chain.Count);

            for (var i = 0; i < values.Length; i++)
            {
                RequestModulesMapping.GetModuleType(values[i]).Should().Be(chain[i].GetType());
            }
        }
예제 #3
0
 /// <summary>
 /// Removes all modules of given <paramref name="moduleType"/> from standard module pipeline.
 /// </summary>
 public static void RemoveRequestModule(this IClusterClientConfiguration configuration, RequestModule moduleType)
 => configuration.ModulesToRemove.Add(RequestModulesMapping.GetModuleType(moduleType));