Beispiel #1
0
        protected virtual void BuildRuntimePipeline()
        {
#if !AWSSDK_UNITY
#if BCL || BCL45
            var httpRequestFactory = new HttpWebRequestFactory();
            var httpHandler        = new HttpHandler <Stream>(httpRequestFactory, this);
#else
            var httpRequestFactory = new HttpRequestMessageFactory(this.Config);
            var httpHandler        = new HttpHandler <System.Net.Http.HttpContent>(httpRequestFactory, this);
#endif
            var preMarshallHandler = new CallbackHandler();
            preMarshallHandler.OnPreInvoke = this.ProcessPreRequestHandlers;

            var postMarshallHandler = new CallbackHandler();
            postMarshallHandler.OnPreInvoke = this.ProcessRequestHandlers;

            var postUnmarshallHandler = new CallbackHandler();
            postUnmarshallHandler.OnPostInvoke = this.ProcessResponseHandlers;

            var errorCallbackHandler = new ErrorCallbackHandler();
            errorCallbackHandler.OnError = this.ProcessExceptionHandlers;

            // Build default runtime pipeline.
            this.RuntimePipeline = new RuntimePipeline(new List <IPipelineHandler>
            {
                httpHandler,
                new Unmarshaller(this.SupportResponseLogging),
                new ErrorHandler(_logger),
                postUnmarshallHandler,
                new Signer(),
                new CredentialsRetriever(this.Credentials),
                new RetryHandler(new DefaultRetryPolicy(this.Config.MaxErrorRetry)),
                postMarshallHandler,
                new EndpointResolver(),
                new Marshaller(),
                preMarshallHandler,
                errorCallbackHandler,
                new MetricsHandler()
            },
                                                       _logger
                                                       );

            CustomizeRuntimePipeline(this.RuntimePipeline);
#endif
        }
        private void BuildRuntimePipeline()
        {
#if BCL
            var httpRequestFactory = new HttpWebRequestFactory(new AmazonSecurityProtocolManager());
            var httpHandler        = new HttpHandler <Stream>(httpRequestFactory, this);
#else
            var httpRequestFactory = new HttpRequestMessageFactory(this.Config);
            var httpHandler        = new HttpHandler <System.Net.Http.HttpContent>(httpRequestFactory, this);
#endif
            var preMarshallHandler = new CallbackHandler();
            preMarshallHandler.OnPreInvoke = this.ProcessPreRequestHandlers;

            var postMarshallHandler = new CallbackHandler();
            postMarshallHandler.OnPreInvoke = this.ProcessRequestHandlers;

            var postUnmarshallHandler = new CallbackHandler();
            postUnmarshallHandler.OnPostInvoke = this.ProcessResponseHandlers;

            var errorCallbackHandler = new ErrorCallbackHandler();
            errorCallbackHandler.OnError = this.ProcessExceptionHandlers;

            //Determine which retry policy to use based on the retry mode
            RetryPolicy retryPolicy;
            switch (this.Config.RetryMode)
            {
            case RequestRetryMode.Adaptive:
                retryPolicy = new AdaptiveRetryPolicy(this.Config);
                break;

            case RequestRetryMode.Standard:
                retryPolicy = new StandardRetryPolicy(this.Config);
                break;

            case RequestRetryMode.Legacy:
                retryPolicy = new DefaultRetryPolicy(this.Config);
                break;

            default:
                throw new InvalidOperationException("Unknown retry mode");
            }

            // Build default runtime pipeline.
            this.RuntimePipeline = new RuntimePipeline(new List <IPipelineHandler>
            {
                httpHandler,
                new Unmarshaller(this.SupportResponseLogging),
                new ErrorHandler(_logger),
                postUnmarshallHandler,
                new Signer(),
                //EndpointDiscoveryResolver must come after CredentialsRetriever, RetryHander, and EndpointResolver as it depends on
                //credentials, retrying of requests for 421 web exceptions, and the current set regional endpoint.
                new EndpointDiscoveryHandler(),
                new CredentialsRetriever(this.Credentials),
                new RetryHandler(retryPolicy),
                postMarshallHandler,
                new EndpointResolver(),
                new Marshaller(),
                preMarshallHandler,
                errorCallbackHandler,
                new MetricsHandler()
            },
                                                       _logger
                                                       );

            if (DeterminedCSMConfiguration.Instance.CSMConfiguration.Enabled && !string.IsNullOrEmpty(ServiceMetadata.ServiceId))
            {
                this.RuntimePipeline.AddHandlerBefore <ErrorHandler>(new CSMCallAttemptHandler());
                this.RuntimePipeline.AddHandlerBefore <MetricsHandler>(new CSMCallEventHandler());
            }

            CustomizeRuntimePipeline(this.RuntimePipeline);

            // Apply global pipeline customizations
            RuntimePipelineCustomizerRegistry.Instance.ApplyCustomizations(this.GetType(), this.RuntimePipeline);
        }
Beispiel #3
0
        private void BuildRuntimePipeline()
        {
#if BCL || BCL45
            var httpRequestFactory = new HttpWebRequestFactory(new AmazonSecurityProtocolManager());
            var httpHandler        = new HttpHandler <Stream>(httpRequestFactory, this);
#elif UNITY
            IHttpRequestFactory <string> httpRequestFactory = null;
            HttpHandler <string>         httpHandler        = null;

            if (AWSConfigs.HttpClient == AWSConfigs.HttpClientOption.UnityWWW)
            {
                httpRequestFactory = new UnityWwwRequestFactory();
                httpHandler        = new HttpHandler <string>(httpRequestFactory, this);
            }
            else
            {
                httpRequestFactory = new UnityWebRequestFactory();
                httpHandler        = new HttpHandler <string>(httpRequestFactory, this);
            }
#else
            var httpRequestFactory = new HttpRequestMessageFactory(this.Config);
            var httpHandler        = new HttpHandler <System.Net.Http.HttpContent>(httpRequestFactory, this);
#endif
            var preMarshallHandler = new CallbackHandler();
            preMarshallHandler.OnPreInvoke = this.ProcessPreRequestHandlers;

            var postMarshallHandler = new CallbackHandler();
            postMarshallHandler.OnPreInvoke = this.ProcessRequestHandlers;

            var postUnmarshallHandler = new CallbackHandler();
            postUnmarshallHandler.OnPostInvoke = this.ProcessResponseHandlers;

            var errorCallbackHandler = new ErrorCallbackHandler();
            errorCallbackHandler.OnError = this.ProcessExceptionHandlers;

            // Build default runtime pipeline.
            this.RuntimePipeline = new RuntimePipeline(new List <IPipelineHandler>
            {
                httpHandler,
                new Unmarshaller(this.SupportResponseLogging),
                new ErrorHandler(_logger),
                postUnmarshallHandler,
                new Signer(),
                new CredentialsRetriever(this.Credentials),
                new RetryHandler(new DefaultRetryPolicy(this.Config)),
                postMarshallHandler,
                new EndpointResolver(),
                new Marshaller(),
                preMarshallHandler,
                errorCallbackHandler,
                new MetricsHandler()
#if UNITY
                , new ThreadPoolExecutionHandler(10)   //remove the hardcoded to unity config
#endif
            },
                                                       _logger
                                                       );

#if BCL || CORECLR
            if (DeterminedCSMConfiguration.Instance.CSMConfiguration.Enabled && !string.IsNullOrEmpty(ServiceMetadata.ServiceId))
            {
                this.RuntimePipeline.AddHandlerBefore <ErrorHandler>(new CSMCallAttemptHandler());
                this.RuntimePipeline.AddHandlerBefore <MetricsHandler>(new CSMCallEventHandler());
            }
#endif

            CustomizeRuntimePipeline(this.RuntimePipeline);

            // Apply global pipeline customizations
            RuntimePipelineCustomizerRegistry.Instance.ApplyCustomizations(this.GetType(), this.RuntimePipeline);
        }
Beispiel #4
0
        private void BuildRuntimePipeline()
        {
#if BCL || BCL45
            var httpRequestFactory = new HttpWebRequestFactory();
            var httpHandler        = new HttpHandler <Stream>(httpRequestFactory, this);
#elif UNITY
            IHttpRequestFactory <string> httpRequestFactory = null;
            HttpHandler <string>         httpHandler        = null;

            if (AWSConfigs.HttpClient == AWSConfigs.HttpClientOption.UnityWWW)
            {
                httpRequestFactory = new UnityWwwRequestFactory();
                httpHandler        = new HttpHandler <string>(httpRequestFactory, this);
            }
            else
            {
                httpRequestFactory = new UnityWebRequestFactory();
                httpHandler        = new HttpHandler <string>(httpRequestFactory, this);
            }
#else
            var httpRequestFactory = new HttpRequestMessageFactory(this.Config);
            var httpHandler        = new HttpHandler <System.Net.Http.HttpContent>(httpRequestFactory, this);
#endif
            var preMarshallHandler = new CallbackHandler();
            preMarshallHandler.OnPreInvoke = this.ProcessPreRequestHandlers;

            var postMarshallHandler = new CallbackHandler();
            postMarshallHandler.OnPreInvoke = this.ProcessRequestHandlers;

            var postUnmarshallHandler = new CallbackHandler();
            postUnmarshallHandler.OnPostInvoke = this.ProcessResponseHandlers;

            var errorCallbackHandler = new ErrorCallbackHandler();
            errorCallbackHandler.OnError = this.ProcessExceptionHandlers;

            // Build default runtime pipeline.
            this.RuntimePipeline = new RuntimePipeline(new List <IPipelineHandler>
            {
                httpHandler,
                new Unmarshaller(this.SupportResponseLogging),
                new ErrorHandler(_logger),
                postUnmarshallHandler,
                new Signer(),
                new CredentialsRetriever(this.Credentials),
                new RetryHandler(new DefaultRetryPolicy(this.Config)),
                postMarshallHandler,
                new EndpointResolver(),
                new Marshaller(),
                preMarshallHandler,
                errorCallbackHandler,
                new MetricsHandler()
#if UNITY
                , new ThreadPoolExecutionHandler(10)   //remove the hardcoded to unity config
#endif
            },
                                                       _logger
                                                       );

            CustomizeRuntimePipeline(this.RuntimePipeline);

            // Apply global pipeline customizations
            RuntimePipelineCustomizerRegistry.Instance.ApplyCustomizations(this.RuntimePipeline);
        }