From 71eda6aeb9fe98d0a58a98e7e227f075ae08ecf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borja=20Garc=C3=ADa=20Rodr=C3=ADguez?= Date: Wed, 23 Dec 2020 10:20:50 +0100 Subject: [PATCH] remove old grpc caller --- .../aggregator/Services/GrpcCallerService.cs | 76 ------------------ .../aggregator/Services/GrpcCallerService.cs | 78 ------------------- 2 files changed, 154 deletions(-) delete mode 100644 src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/GrpcCallerService.cs delete mode 100644 src/ApiGateways/Web.Bff.Shopping/aggregator/Services/GrpcCallerService.cs diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/GrpcCallerService.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/GrpcCallerService.cs deleted file mode 100644 index 55f3df3ee..000000000 --- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/GrpcCallerService.cs +++ /dev/null @@ -1,76 +0,0 @@ -using Grpc.Core; -using Grpc.Net.Client; -using Serilog; -using System; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services -{ - public static class GrpcCallerService - { - public static async Task CallService(string urlGrpc, Func> func) - { - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true); - - var channel = GrpcChannel.ForAddress(urlGrpc); - - /* - using var httpClientHandler = new HttpClientHandler - { - ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; } - }; - - */ - - - Log.Information("Creating grpc client base address urlGrpc ={@urlGrpc}, BaseAddress={@BaseAddress} ", urlGrpc, channel.Target); - - try - { - return await func(channel); - } - catch (RpcException e) - { - Log.Error("Error calling via grpc: {Status} - {Message}", e.Status, e.Message); - return default; - } - finally - { - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", false); - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", false); - } - } - - public static async Task CallService(string urlGrpc, Func func) - { - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true); - - /* - using var httpClientHandler = new HttpClientHandler - { - ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; } - }; - */ - - var channel = GrpcChannel.ForAddress(urlGrpc); - - Log.Debug("Creating grpc client base address {@httpClient.BaseAddress} ", channel.Target); - - try - { - await func(channel); - } - catch (RpcException e) - { - Log.Error("Error calling via grpc: {Status} - {Message}", e.Status, e.Message); - } - finally - { - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", false); - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", false); - } - } - } -} diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/GrpcCallerService.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/GrpcCallerService.cs deleted file mode 100644 index 2039c7c4f..000000000 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/GrpcCallerService.cs +++ /dev/null @@ -1,78 +0,0 @@ -using Grpc.Core; -using Grpc.Net.Client; -using Serilog; -using System; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services -{ - public static class GrpcCallerService - { - public static async Task CallService(string urlGrpc, Func> func) - { - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true); - - var channel = GrpcChannel.ForAddress(urlGrpc); - - /* - using var httpClientHandler = new HttpClientHandler - { - ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; } - }; - - */ - - - Log.Information("Creating grpc client base address urlGrpc ={@urlGrpc}, BaseAddress={@BaseAddress} ", urlGrpc, channel.Target); - - try - { - return await func(channel); - } - catch (RpcException e) - { - Log.Error("Error calling via grpc: {Status} - {Message}", e.Status, e.Message); - return default; - } - finally - { - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", false); - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", false); - } - - - } - - public static async Task CallService(string urlGrpc, Func func) - { - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true); - - /* - using var httpClientHandler = new HttpClientHandler - { - ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; } - }; - */ - - var channel = GrpcChannel.ForAddress(urlGrpc); - - Log.Debug("Creating grpc client base address {@httpClient.BaseAddress} ", channel.Target); - - try - { - await func(channel); - } - catch (RpcException e) - { - Log.Error("Error calling via grpc: {Status} - {Message}", e.Status, e.Message); - } - finally - { - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", false); - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", false); - } - } - } -}