public void Should_always_return_different_per_instance_providers()
        {
            var provider1 = ReplicaStorageProviderFactory.Create(ReplicaStorageScope.Instance);
            var provider2 = ReplicaStorageProviderFactory.Create(ReplicaStorageScope.Instance);

            provider2.Should().NotBeSameAs(provider1);
        }
        public void Should_always_return_same_per_process_provider()
        {
            var provider1 = ReplicaStorageProviderFactory.Create(ReplicaStorageScope.Process);
            var provider2 = ReplicaStorageProviderFactory.Create(ReplicaStorageScope.Process);

            provider2.Should().BeSameAs(provider1);
        }
Beispiel #3
0
        /// <summary>
        /// Creates a <see cref="ClusterClient"/> instance using given <paramref name="log"/> and <paramref name="setup"/> delegate.
        /// </summary>
        /// <exception cref="ClusterClientException">Configuration was incomplete or invalid.</exception>
        public ClusterClient(ILog log, ClusterClientSetup setup)
        {
            configuration = new ClusterClientConfiguration(log ?? new SilentLog());

            setup(configuration);

            configuration.ValidateOrDie();
            configuration.AugmentWithDefaults();

            if (configuration.ReplicaTransform != null)
            {
                configuration.ClusterProvider = new TransformingClusterProvider(configuration.ClusterProvider, configuration.ReplicaTransform);
            }

            if (configuration.TransferDistributedContext)
            {
                configuration.Transport = new TransportWithDistributedContext(configuration.Transport);
            }

            if (configuration.EnableTracing)
            {
                configuration.Transport = new TransportWithTracing(configuration.Transport);
            }

            configuration.Transport = new TransportWithAuxiliaryHeaders(configuration.Transport, configuration);

            ReplicaStorageProvider = ReplicaStorageProviderFactory.Create(configuration.ReplicaStorageScope);

            var modules = RequestModuleChainBuilder.BuildChain(configuration, ReplicaStorageProvider);

            pipelineDelegate = RequestModuleChainBuilder.BuildChainDelegate(modules);
        }
        /// <summary>
        /// Creates a <see cref="ClusterClient"/> instance using given <paramref name="log"/> and <paramref name="setup"/> delegate.
        /// </summary>
        /// <exception cref="ClusterClientException">Configuration was incomplete or invalid.</exception>
        public ClusterClient(ILog log, ClusterClientSetup setup)
        {
            configuration = new ClusterClientConfiguration(log ?? new SilentLog());

            setup(configuration);

            configuration.ValidateOrDie();
            configuration.AugmentWithDefaults();
            configuration.ApplyReplicaTransform();
            configuration.SetupRequestTimeoutHeader();

            ReplicaStorageProvider = ReplicaStorageProviderFactory.Create(configuration.ReplicaStorageScope);

            var modules = RequestModuleChainBuilder.BuildChain(configuration, ReplicaStorageProvider);

            pipelineDelegate = RequestModuleChainBuilder.BuildChainDelegate(modules);

            defaultParameters = RequestParameters.Empty
                                .WithStrategy(configuration.DefaultRequestStrategy)
                                .WithPriority(configuration.DefaultPriority)
                                .WithConnectionTimeout(configuration.DefaultConnectionTimeout);
        }
 public void Should_return_per_process_provider_for_process_scope()
 {
     ReplicaStorageProviderFactory.Create(ReplicaStorageScope.Process).Should().BeOfType <PerProcessReplicaStorageProvider>();
 }
 public void Should_return_per_instance_provider_for_instance_scope()
 {
     ReplicaStorageProviderFactory.Create(ReplicaStorageScope.Instance).Should().BeOfType <PerInstanceReplicaStorageProvider>();
 }