示例#1
0
        public void RequestPipeline()
        {
            // hide
            var settings = TestClient.DefaultInMemoryClient.ConnectionSettings;

            /** When calling `Request()` or `RequestAsync()` on an `ITransport`,
             * the whole coordination of the request is deferred to a new instance in a `using` block.
             */
            var pipeline = new RequestPipeline <IConnectionSettingsValues>(
                settings,
                DateTimeProvider.Default,
                new RecyclableMemoryStreamFactory(),
                new SearchRequestParameters()
                );

            pipeline.GetType().Should().Implement <IDisposable>();

            /** An `ITransport` does not instantiate a `RequestPipeline` directly; it uses a pluggable `IRequestPipelineFactory`
             * to create them
             */
            var requestPipelineFactory = new RequestPipelineFactory <IConnectionSettingsValues>();
            var requestPipeline        = requestPipelineFactory.Create(
                settings,
                DateTimeProvider.Default,                 //<1> An <<date-time-providers,`IDateTimeProvider`>> implementation
                new RecyclableMemoryStreamFactory(),
                new SearchRequestParameters()
                );

            requestPipeline.Should().BeOfType <RequestPipeline <IConnectionSettingsValues> >();
            requestPipeline.GetType().Should().Implement <IDisposable>();

            /**
             * You can pass your own `IRequestPipeline` implementation to the transport when instantiating a client,
             * allowing you to have requests executed in your own custom request pipeline
             */
            var transport = new Transport <IConnectionSettingsValues>(
                settings,
                requestPipelineFactory,
                DateTimeProvider.Default,
                new RecyclableMemoryStreamFactory()
                );

            var client = new ElasticClient(transport);
        }
		public void RequestPipeline()
		{
			var settings = TestClient.CreateSettings();

			/** When calling Request(Async) on Transport the whole coordination of the request is deferred to a new instance in a `using` block. */
			var pipeline = new RequestPipeline(settings, DateTimeProvider.Default, new MemoryStreamFactory(), new SearchRequestParameters());
			pipeline.GetType().Should().Implement<IDisposable>();

			/** However the transport does not instantiate RequestPipeline directly, it uses a pluggable `IRequestPipelineFactory`*/
			var requestPipelineFactory = new RequestPipelineFactory();
			var requestPipeline = requestPipelineFactory.Create(settings, DateTimeProvider.Default, new MemoryStreamFactory(), new SearchRequestParameters());
			requestPipeline.Should().BeOfType<RequestPipeline>();
			requestPipeline.GetType().Should().Implement<IDisposable>();

			/** which can be passed to the transport when instantiating a client */
			var transport = new Transport<ConnectionSettings>(settings, requestPipelineFactory, DateTimeProvider.Default, new MemoryStreamFactory());

			/** this allows you to have requests executed on your own custom request pipeline */
		}
        public void RequestPipeline()
        {
            var settings = TestClient.CreateSettings();

            /** When calling Request(Async) on Transport the whole coordination of the request is deferred to a new instance in a `using` block. */
            var pipeline = new RequestPipeline(settings, DateTimeProvider.Default, new MemoryStreamFactory(), new SearchRequestParameters());

            pipeline.GetType().Should().Implement <IDisposable>();

            /** However the transport does not instantiate RequestPipeline directly, it uses a pluggable `IRequestPipelineFactory`*/
            var requestPipelineFactory = new RequestPipelineFactory();
            var requestPipeline        = requestPipelineFactory.Create(settings, DateTimeProvider.Default, new MemoryStreamFactory(), new SearchRequestParameters());

            requestPipeline.Should().BeOfType <RequestPipeline>();
            requestPipeline.GetType().Should().Implement <IDisposable>();

            /** which can be passed to the transport when instantiating a client */
            var transport = new Transport <ConnectionSettings>(settings, requestPipelineFactory, DateTimeProvider.Default, new MemoryStreamFactory());

            /** this allows you to have requests executed on your own custom request pipeline */
        }
		public void RequestPipeline()
		{
			var settings = TestClient.CreateSettings();

			/** When calling `Request()` or `RequestAsync()` on an `ITransport`,
			* the whole coordination of the request is deferred to a new instance in a `using` block.
			*/
			var pipeline = new RequestPipeline(
				settings,
				DateTimeProvider.Default,
				new MemoryStreamFactory(),
				new SearchRequestParameters());

			pipeline.GetType().Should().Implement<IDisposable>();

			/** An `ITransport` does not instantiate a `RequestPipeline` directly; it uses a pluggable `IRequestPipelineFactory`
			* to create it
			*/
			var requestPipelineFactory = new RequestPipelineFactory();
			var requestPipeline = requestPipelineFactory.Create(
				settings,
				DateTimeProvider.Default, //<1> An <<date-time-providers,`IDateTimeProvider` implementation>>
				new MemoryStreamFactory(),
				new SearchRequestParameters());

			requestPipeline.Should().BeOfType<RequestPipeline>();
			requestPipeline.GetType().Should().Implement<IDisposable>();

			/** You can pass your own `IRequestPipeline` implementation to the Transport when instantiating a client,
			* allowing you to have requests executed on your own custom request pipeline
			*/
			var transport = new Transport<ConnectionSettings>(
				settings,
				requestPipelineFactory,
				DateTimeProvider.Default,
				new MemoryStreamFactory());
		}