From 84d69e8ded68603bdfa22f6b89dbbfc78588ad5f Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Wed, 20 Oct 2021 18:34:58 +0300 Subject: [PATCH] removed consul --- .../AdministrationServiceHttpApiHostModule.cs | 1 - .../IdentityServiceHttpApiHostModule.cs | 1 - .../SaasServiceHttpApiHostModule.cs | 1 - .../EShopOnAbp.Shared.Hosting.Gateways.csproj | 1 - .../EShopOnAbpSharedHostingGatewaysModule.cs | 3 - .../ConsulConfigurationExtensions.cs | 60 ------------------- ...pOnAbp.Shared.Hosting.Microservices.csproj | 1 - ...opOnAbpSharedHostingMicroservicesModule.cs | 3 - 8 files changed, 71 deletions(-) delete mode 100644 shared/EShopOnAbp.Shared.Hosting.Microservices/ConsulConfigurationExtensions.cs diff --git a/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs b/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs index 74f65e11..2e64a6ab 100644 --- a/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs +++ b/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs @@ -98,7 +98,6 @@ namespace EShopOnAbp.AdministrationService app.UseAbpSerilogEnrichers(); app.UseAuditing(); app.UseUnitOfWork(); - app.UseConsul(); app.UseConfiguredEndpoints(endpoints => { //endpoints.MapMetrics(); diff --git a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs index 6b760721..80122c46 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs +++ b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs @@ -91,7 +91,6 @@ namespace EShopOnAbp.IdentityService app.UseAbpSerilogEnrichers(); app.UseAuditing(); app.UseUnitOfWork(); - app.UseConsul(); app.UseConfiguredEndpoints(endpoints => { // endpoints.MapMetrics(); diff --git a/services/saas/src/EShopOnAbp.SaasService.HttpApi.Host/SaasServiceHttpApiHostModule.cs b/services/saas/src/EShopOnAbp.SaasService.HttpApi.Host/SaasServiceHttpApiHostModule.cs index 26e040ee..72a2cf94 100644 --- a/services/saas/src/EShopOnAbp.SaasService.HttpApi.Host/SaasServiceHttpApiHostModule.cs +++ b/services/saas/src/EShopOnAbp.SaasService.HttpApi.Host/SaasServiceHttpApiHostModule.cs @@ -98,7 +98,6 @@ namespace EShopOnAbp.SaasService app.UseAbpSerilogEnrichers(); app.UseAuditing(); app.UseUnitOfWork(); - app.UseConsul(); app.UseConfiguredEndpoints(endpoints => { // endpoints.MapMetrics(); diff --git a/shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbp.Shared.Hosting.Gateways.csproj b/shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbp.Shared.Hosting.Gateways.csproj index 204aa15d..2621e58c 100644 --- a/shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbp.Shared.Hosting.Gateways.csproj +++ b/shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbp.Shared.Hosting.Gateways.csproj @@ -7,7 +7,6 @@ - diff --git a/shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbpSharedHostingGatewaysModule.cs b/shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbpSharedHostingGatewaysModule.cs index c0227815..895cfabf 100644 --- a/shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbpSharedHostingGatewaysModule.cs +++ b/shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbpSharedHostingGatewaysModule.cs @@ -1,11 +1,9 @@ using EShopOnAbp.Shared.Hosting.AspNetCore; using Microsoft.Extensions.DependencyInjection; using Ocelot.DependencyInjection; -using Ocelot.Provider.Consul; using Ocelot.Provider.Polly; using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; using Volo.Abp.Modularity; -using Volo.Abp.Swashbuckle; namespace EShopOnAbp.Shared.Hosting.Gateways { @@ -20,7 +18,6 @@ namespace EShopOnAbp.Shared.Hosting.Gateways var configuration = context.Services.GetConfiguration(); context.Services.AddOcelot(configuration) - .AddConsul() .AddPolly(); } } diff --git a/shared/EShopOnAbp.Shared.Hosting.Microservices/ConsulConfigurationExtensions.cs b/shared/EShopOnAbp.Shared.Hosting.Microservices/ConsulConfigurationExtensions.cs deleted file mode 100644 index 16c795c3..00000000 --- a/shared/EShopOnAbp.Shared.Hosting.Microservices/ConsulConfigurationExtensions.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using Consul; -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; - -namespace EShopOnAbp.Shared.Hosting.Microservices -{ - public static class ConsulConfigurationExtensions - { - public static IServiceCollection AddConsulConfig(this IServiceCollection services, IConfiguration configuration) - { - services.AddSingleton(p => new ConsulClient(consulConfig => - { - var address = configuration.GetValue("Consul:Host"); - consulConfig.Address = new Uri(address); - })); - return services; - } - - public static string UseConsul(this IApplicationBuilder app) - { - var appLifetime = app.ApplicationServices.GetService(); - using (var scope = app.ApplicationServices.CreateScope()) - { - var configuration = scope.ServiceProvider.GetService(); - - bool isEnabled = configuration.GetValue("Consul:Enabled"); - string serviceName = configuration.GetValue("Consul:Service"); - var appString = configuration.GetValue("App:SelfUrl"); - Uri appUrl = new Uri(appString, UriKind.Absolute); - - if (!isEnabled) - return String.Empty; - - Guid serviceId = Guid.NewGuid(); - string consulServiceID = $"{serviceName}:{serviceId}"; - - var client = scope.ServiceProvider.GetService(); - - var consulServiceRegistration = new AgentServiceRegistration - { - Name = serviceName, - ID = consulServiceID, - Address = appUrl.Host, - Port = appUrl.Port - }; - - client.Agent.ServiceRegister(consulServiceRegistration); - appLifetime.ApplicationStopping.Register(() => - { - client.Agent.ServiceDeregister(consulServiceRegistration.ID); - }); - - return consulServiceID; - } - } - } -} \ No newline at end of file diff --git a/shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbp.Shared.Hosting.Microservices.csproj b/shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbp.Shared.Hosting.Microservices.csproj index af2b2407..8edbb281 100644 --- a/shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbp.Shared.Hosting.Microservices.csproj +++ b/shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbp.Shared.Hosting.Microservices.csproj @@ -12,7 +12,6 @@ - diff --git a/shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbpSharedHostingMicroservicesModule.cs b/shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbpSharedHostingMicroservicesModule.cs index 62c6eb0b..f2554fb3 100644 --- a/shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbpSharedHostingMicroservicesModule.cs +++ b/shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbpSharedHostingMicroservicesModule.cs @@ -2,7 +2,6 @@ using EShopOnAbp.SaasService.EntityFrameworkCore; using EShopOnAbp.Shared.Hosting.AspNetCore; using Microsoft.AspNetCore.DataProtection; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using StackExchange.Redis; using Volo.Abp.AspNetCore.MultiTenancy; @@ -45,8 +44,6 @@ namespace EShopOnAbp.Shared.Hosting.Microservices context.Services .AddDataProtection() .PersistKeysToStackExchangeRedis(redis, "EShopOnAbp-Protection-Keys"); - - context.Services.AddConsulConfig(configuration); } } } \ No newline at end of file