示例#1
0
        public async Task <HttpResponseMessage> ProxyToService(FabricAddress fabricAddress, HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var client = new ServicePartitionClient <HttpCommunicationClient>(this.communicationClientFactory, fabricAddress.Uri);

            return(await client.InvokeWithRetryAsync(c =>
            {
                var serviceUri = GetServiceUri(c.Url, request.RequestUri);
                return ProxyRequest(serviceUri, request, c.HttpClient);
            },
                                                     cancellationToken));
        }
        public async Task <HttpResponseMessage> ProxyToService(FabricAddress fabricAddress, HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var client = new ServicePartitionClient <HttpCommunicationClient>(this.communicationClientFactory, fabricAddress.Uri, retrySettings: this.operationRetrySettings);

            await request.Content.LoadIntoBufferAsync();

            return(await client.InvokeWithRetryAsync(async c =>
            {
                try
                {
                    var serviceUri = GetServiceUri(c.Url, request.RequestUri);
                    return await ProxyRequest(serviceUri, request, c.HttpClient);
                }
                catch (Exception ex)
                {
                    ex.Data.Add("Resolved Service Uri", c.Url);
                    throw;
                }
            },
                                                     cancellationToken));
        }