Browse Source

removed consul

enisn/payment-service-with-mock
Galip Tolga Erdem 5 years ago
parent
commit
84d69e8ded
  1. 1
      services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs
  2. 1
      services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs
  3. 1
      services/saas/src/EShopOnAbp.SaasService.HttpApi.Host/SaasServiceHttpApiHostModule.cs
  4. 1
      shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbp.Shared.Hosting.Gateways.csproj
  5. 3
      shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbpSharedHostingGatewaysModule.cs
  6. 60
      shared/EShopOnAbp.Shared.Hosting.Microservices/ConsulConfigurationExtensions.cs
  7. 1
      shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbp.Shared.Hosting.Microservices.csproj
  8. 3
      shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbpSharedHostingMicroservicesModule.cs

1
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();

1
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();

1
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();

1
shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbp.Shared.Hosting.Gateways.csproj

@ -7,7 +7,6 @@
<ItemGroup>
<PackageReference Include="Ocelot" Version="17.0.0" />
<PackageReference Include="Ocelot.Provider.Polly" Version="17.0.0" />
<PackageReference Include="Ocelot.Provider.Consul" Version="17.0.0" />
</ItemGroup>
<ItemGroup>

3
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();
}
}

60
shared/EShopOnAbp.Shared.Hosting.Microservices/ConsulConfigurationExtensions.cs

@ -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<IConsulClient>(p => new ConsulClient(consulConfig =>
{
var address = configuration.GetValue<string>("Consul:Host");
consulConfig.Address = new Uri(address);
}));
return services;
}
public static string UseConsul(this IApplicationBuilder app)
{
var appLifetime = app.ApplicationServices.GetService<IHostApplicationLifetime>();
using (var scope = app.ApplicationServices.CreateScope())
{
var configuration = scope.ServiceProvider.GetService<IConfiguration>();
bool isEnabled = configuration.GetValue<bool>("Consul:Enabled");
string serviceName = configuration.GetValue<string>("Consul:Service");
var appString = configuration.GetValue<string>("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<IConsulClient>();
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;
}
}
}
}

1
shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbp.Shared.Hosting.Microservices.csproj

@ -12,7 +12,6 @@
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="6.0.0-rc.1.21452.15" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.0-rc.1.21452.15" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.1" />
<PackageReference Include="Consul.AspNetCore" Version="1.6.10.3" />
</ItemGroup>
<ItemGroup>

3
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);
}
}
}
Loading…
Cancel
Save