Browse Source

Merge pull request #16 from abpframework/gterdem/consul_remove

Remove Consul
enisn/payment-service-with-mock
Enis Necipoglu 5 years ago
committed by GitHub
parent
commit
67e68288eb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      etc/docker/docker-compose.infrastructure.override.yml
  2. 6
      etc/docker/docker-compose.infrastructure.yml
  3. 4
      gateways/internal/src/EShopOnAbp.InternalGateway/EShopOnAbpInternalGatewayModule.cs
  4. 16
      gateways/internal/src/EShopOnAbp.InternalGateway/appsettings.json
  5. 4
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs
  6. 10
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.json
  7. 4
      gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs
  8. 14
      gateways/web/src/EShopOnAbp.WebGateway/appsettings.json
  9. 1
      services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs
  10. 1
      services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs
  11. 1
      services/saas/src/EShopOnAbp.SaasService.HttpApi.Host/SaasServiceHttpApiHostModule.cs
  12. 1
      shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbp.Shared.Hosting.Gateways.csproj
  13. 3
      shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbpSharedHostingGatewaysModule.cs
  14. 2
      shared/EShopOnAbp.Shared.Hosting.Gateways/OcelotConfiguration.cs
  15. 60
      shared/EShopOnAbp.Shared.Hosting.Microservices/ConsulConfigurationExtensions.cs
  16. 1
      shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbp.Shared.Hosting.Microservices.csproj
  17. 3
      shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbpSharedHostingMicroservicesModule.cs

5
etc/docker/docker-compose.infrastructure.override.yml

@ -16,8 +16,3 @@ services:
environment:
SA_PASSWORD: "myPassw0rd"
ACCEPT_EULA: "Y"
consul:
ports:
- "8500:8500"
- "8600:8600"

6
etc/docker/docker-compose.infrastructure.yml

@ -20,12 +20,6 @@ services:
- sqldata:/var/opt/mssql
networks:
- eshoponabp-network
consul:
container_name: consul
image: consul
networks:
- eshoponabp-network
volumes:
sqldata:

4
gateways/internal/src/EShopOnAbp.InternalGateway/EShopOnAbpInternalGatewayModule.cs

@ -41,12 +41,12 @@ namespace EShopOnAbp.InternalGateway
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
var routes = configuration.GetSection("Routes").Get<List<OcelotConfiguration>>();
foreach (var config in routes.GroupBy(t => t.ServiceName).Select(r => r.First()).Distinct())
foreach (var config in routes.GroupBy(t => t.ServiceKey).Select(r => r.First()).Distinct())
{
var url =
$"{config.DownstreamScheme}://{config.DownstreamHostAndPorts.FirstOrDefault()?.Host}:{config.DownstreamHostAndPorts.FirstOrDefault()?.Port}";
options.SwaggerEndpoint($"{url}/swagger/v1/swagger.json", $"{config.ServiceName} API");
options.SwaggerEndpoint($"{url}/swagger/v1/swagger.json", $"{config.ServiceKey} API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
}

16
gateways/internal/src/EShopOnAbp.InternalGateway/appsettings.json

@ -12,7 +12,7 @@
"AllowedHosts": "*",
"Routes": [
{
"ServiceName": "Identity Service",
"ServiceKey": "Identity Service",
"DownstreamPathTemplate": "/api/identity/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -25,7 +25,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Identity Service",
"ServiceKey": "Identity Service",
"DownstreamPathTemplate": "/api/account/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -38,7 +38,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Saas Service",
"ServiceKey": "Saas Service",
"DownstreamPathTemplate": "/api/saas/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -51,7 +51,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Administration Service",
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/abp/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -64,7 +64,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Administration Service",
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/feature-management/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -77,7 +77,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Administration Service",
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/permission-management/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -90,7 +90,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Administration Service",
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/setting-management/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -103,7 +103,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Payment Service",
"ServiceKey": "Payment Service",
"DownstreamPathTemplate": "/api/payment/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [

4
gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs

@ -41,12 +41,12 @@ namespace EShopOnAbp.WebPublicGateway
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
var routes = configuration.GetSection("Routes").Get<List<OcelotConfiguration>>();
foreach (var config in routes.GroupBy(t => t.ServiceName).Select(r => r.First()).Distinct())
foreach (var config in routes.GroupBy(t => t.ServiceKey).Select(r => r.First()).Distinct())
{
var url =
$"{config.DownstreamScheme}://{config.DownstreamHostAndPorts.FirstOrDefault()?.Host}:{config.DownstreamHostAndPorts.FirstOrDefault()?.Port}";
options.SwaggerEndpoint($"{url}/swagger/v1/swagger.json", $"{config.ServiceName} API");
options.SwaggerEndpoint($"{url}/swagger/v1/swagger.json", $"{config.ServiceKey} API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
}

10
gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.json

@ -19,7 +19,7 @@
"AllowedHosts": "*",
"Routes": [
{
"ServiceName": "Identity Service",
"ServiceKey": "Identity Service",
"DownstreamPathTemplate": "/api/account/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -32,7 +32,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Administration Service",
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/abp/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -45,7 +45,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Catalog Service",
"ServiceKey": "Catalog Service",
"DownstreamPathTemplate": "/api/catalog/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -58,7 +58,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Basket Service",
"ServiceKey": "Basket Service",
"DownstreamPathTemplate": "/api/basket/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -71,7 +71,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Ordering Service",
"ServiceKey": "Ordering Service",
"DownstreamPathTemplate": "/api/ordering/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [

4
gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs

@ -44,12 +44,12 @@ namespace EShopOnAbp.WebGateway
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
var routes = configuration.GetSection("Routes").Get<List<OcelotConfiguration>>();
foreach (var config in routes.GroupBy(t => t.ServiceName).Select(r => r.First()).Distinct())
foreach (var config in routes.GroupBy(t => t.ServiceKey).Select(r => r.First()).Distinct())
{
var url =
$"{config.DownstreamScheme}://{config.DownstreamHostAndPorts.FirstOrDefault()?.Host}:{config.DownstreamHostAndPorts.FirstOrDefault()?.Port}";
options.SwaggerEndpoint($"{url}/swagger/v1/swagger.json", $"{config.ServiceName} API");
options.SwaggerEndpoint($"{url}/swagger/v1/swagger.json", $"{config.ServiceKey} API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
}

14
gateways/web/src/EShopOnAbp.WebGateway/appsettings.json

@ -19,7 +19,7 @@
"AllowedHosts": "*",
"Routes": [
{
"ServiceName": "Identity Service",
"ServiceKey": "Identity Service",
"DownstreamPathTemplate": "/api/identity/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -32,7 +32,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Identity Service",
"ServiceKey": "Identity Service",
"DownstreamPathTemplate": "/api/account/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -45,7 +45,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Saas Service",
"ServiceKey": "Saas Service",
"DownstreamPathTemplate": "/api/multi-tenancy/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -58,7 +58,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Administration Service",
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/abp/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -71,7 +71,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Administration Service",
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/feature-management/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -84,7 +84,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Administration Service",
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/permission-management/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
@ -97,7 +97,7 @@
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"ServiceName": "Administration Service",
"ServiceKey": "Administration Service",
"DownstreamPathTemplate": "/api/setting-management/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [

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

2
shared/EShopOnAbp.Shared.Hosting.Gateways/OcelotConfiguration.cs

@ -4,7 +4,7 @@ namespace EShopOnAbp.Shared.Hosting.Gateways
{
public class OcelotConfiguration
{
public string ServiceName { get; set; }
public string ServiceKey { get; set; }
public string DownstreamPathTemplate { get; set; }
public string DownstreamScheme { get; set; }
public string UpstreamPathTemplate { get; set; }

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