From 9c7ad7411ab3323b0f9cc2d3bf6890aa06967d2f Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Mon, 31 Jan 2022 18:11:36 +0300 Subject: [PATCH] Removed custom urls and added GrpcUrl to Catalog remote service --- .../BasketServiceApplicationModule.cs | 19 +++++++++---------- .../Configs/UrlsConfig.cs | 7 ------- .../appsettings.Development.json | 4 ---- .../appsettings.json | 3 ++- 4 files changed, 11 insertions(+), 22 deletions(-) delete mode 100644 services/basket/src/EShopOnAbp.BasketService.Application/Configs/UrlsConfig.cs diff --git a/services/basket/src/EShopOnAbp.BasketService.Application/BasketServiceApplicationModule.cs b/services/basket/src/EShopOnAbp.BasketService.Application/BasketServiceApplicationModule.cs index 1d3f7cdc..2cf26502 100644 --- a/services/basket/src/EShopOnAbp.BasketService.Application/BasketServiceApplicationModule.cs +++ b/services/basket/src/EShopOnAbp.BasketService.Application/BasketServiceApplicationModule.cs @@ -1,12 +1,11 @@ using System; -using EShopOnAbp.BasketService.Configs; -using EShopOnAbp.BasketService.Grpc; +using System.Collections.Generic; using EShopOnAbp.CatalogService; using EShopOnAbp.CatalogService.Grpc; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; using Volo.Abp.Application; using Volo.Abp.AutoMapper; +using Volo.Abp.Http.Client; using Volo.Abp.Modularity; namespace EShopOnAbp.BasketService @@ -23,19 +22,19 @@ namespace EShopOnAbp.BasketService public override void ConfigureServices(ServiceConfigurationContext context) { var configuration = context.Services.GetConfiguration(); - context.Services.AddOptions(); - context.Services.Configure(configuration.GetSection("urls")); - Configure(options => { options.AddMaps(); }); - + context.Services.AddGrpcClient((services, options) => { - var catalogApi = services.GetRequiredService>().Value.GrpcCatalog; - options.Address = new Uri(catalogApi); - }).AddInterceptor(); + var remoteServiceConfigurationProvider = services.GetRequiredService(); + var catalogServiceConfiguration = remoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("Catalog").Result; + var catalogGrpcUrl = catalogServiceConfiguration.GetOrDefault("GrpcUrl"); + + options.Address = new Uri(catalogGrpcUrl); + }); } } } diff --git a/services/basket/src/EShopOnAbp.BasketService.Application/Configs/UrlsConfig.cs b/services/basket/src/EShopOnAbp.BasketService.Application/Configs/UrlsConfig.cs deleted file mode 100644 index d45a3b3e..00000000 --- a/services/basket/src/EShopOnAbp.BasketService.Application/Configs/UrlsConfig.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace EShopOnAbp.BasketService.Configs; - -public class UrlsConfig -{ - public string Catalog { get; set; } - public string GrpcCatalog { get; set; } -} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.Development.json b/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.Development.json index 4ea1f3f6..2c63c085 100644 --- a/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.Development.json +++ b/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.Development.json @@ -1,6 +1,2 @@ { - "urls": { - "catalog": "https://localhost:44354", - "grpcCatalog": "http://localhost:81" - } } diff --git a/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.json b/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.json index 2e9949c5..93adbecc 100644 --- a/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.json +++ b/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.json @@ -11,7 +11,8 @@ }, "RemoteServices": { "Catalog": { - "BaseUrl": "https://localhost:44354/" + "BaseUrl": "https://localhost:44354/", + "GrpcUrl": "http://localhost:81" } }, "Logging": {