Browse Source

gateway updates

pull/248/head
Galip Tolga Erdem 2 years ago
parent
commit
cb21aa15d6
  1. 18
      aspire/AppHost/Program.cs
  2. 4
      aspire/ServiceDefaults/eShopOnAbp.ServiceDefaults.csproj
  3. 16
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/yarp.json
  4. 11
      services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs
  5. 6
      shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj
  6. 3
      shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbp.Shared.Hosting.Gateways.csproj
  7. 13
      shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbpSharedHostingGatewaysModule.cs

18
aspire/AppHost/Program.cs

@ -1,10 +1,12 @@
var builder = DistributedApplication.CreateBuilder(args); var builder = DistributedApplication.CreateBuilder(args);
var launchProfile = "HTTP";
// Microservices // Microservices
var administrationService = var administrationService =
builder.AddProject<Projects.EShopOnAbp_AdministrationService_HttpApi_Host>("administrationService"); builder.AddProject<Projects.EShopOnAbp_AdministrationService_HttpApi_Host>("administrationService",launchProfile);
var identityService = builder.AddProject<Projects.EShopOnAbp_IdentityService_HttpApi_Host>("identityService"); var identityService = builder.AddProject<Projects.EShopOnAbp_IdentityService_HttpApi_Host>("identityService");
var catalogService = builder.AddProject<Projects.EShopOnAbp_CatalogService_HttpApi_Host>("catalogService"); var catalogService = builder.AddProject<Projects.EShopOnAbp_CatalogService_HttpApi_Host>("catalogService")
.AsHttp2Service();
var basketService = builder.AddProject<Projects.EShopOnAbp_BasketService>("basketService") var basketService = builder.AddProject<Projects.EShopOnAbp_BasketService>("basketService")
.WithReference(catalogService); //? .WithReference(catalogService); //?
var cmsKitService = builder.AddProject<Projects.EShopOnAbp_CmskitService_HttpApi_Host>("cmsKitService"); var cmsKitService = builder.AddProject<Projects.EShopOnAbp_CmskitService_HttpApi_Host>("cmsKitService");
@ -13,9 +15,17 @@ var paymentService = builder.AddProject<Projects.EShopOnAbp_PaymentService_HttpA
// Gateways // Gateways
var webGateway = builder.AddProject<Projects.EShopOnAbp_WebGateway>("webGateway"); var webGateway = builder.AddProject<Projects.EShopOnAbp_WebGateway>("webGateway");
var webPublicGateway = builder.AddProject<Projects.EShopOnAbp_WebPublicGateway>("webPublicGateway"); var webPublicGateway = builder.AddProject<Projects.EShopOnAbp_WebPublicGateway>("webPublicGateway")
.WithReference(administrationService)
.WithReference(identityService)
.WithReference(catalogService)
.WithReference(basketService)
.WithReference(cmsKitService)
.WithReference(orderingService)
.WithReference(paymentService);
// Apps // Apps
var publicWebApp = builder.AddProject<Projects.EShopOnAbp_PublicWeb>("public-web"); var publicWebApp = builder.AddProject<Projects.EShopOnAbp_PublicWeb>("public-web")
.WithExternalHttpEndpoints();
builder.Build().Run(); builder.Build().Run();

4
aspire/ServiceDefaults/eShopOnAbp.ServiceDefaults.csproj

@ -10,8 +10,8 @@
<ItemGroup> <ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" /> <FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.3.0" /> <PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.5.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.0-preview.7.24251.11" /> <PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.8.1" /> <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.8.1" /> <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" /> <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />

16
gateways/web-public/src/EShopOnAbp.WebPublicGateway/yarp.json

@ -142,7 +142,7 @@
"Identity": { "Identity": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44351", "Address": "http://identityService",
"MetaData": { "MetaData": {
"PublicAddress": "https://identity.eshoponabp.dev" "PublicAddress": "https://identity.eshoponabp.dev"
} }
@ -152,7 +152,7 @@
"Administration": { "Administration": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44353", "Address": "http://admininstrationService",
"MetaData": { "MetaData": {
"PublicAddress": "https://admininstration.eshop.dev" "PublicAddress": "https://admininstration.eshop.dev"
} }
@ -162,9 +162,9 @@
"catalogCluster": { "catalogCluster": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44354", "Address": "http://catalogService",
"MetaData": { "MetaData": {
"PublicAddress": "https://admininstration.eshoponabp.dev" "PublicAddress": "https://catalog.eshoponabp.dev"
} }
} }
} }
@ -172,7 +172,7 @@
"Basket": { "Basket": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44355", "Address": "http://basketService",
"MetaData": { "MetaData": {
"PublicAddress": "https://basket.eshoponabp.dev" "PublicAddress": "https://basket.eshoponabp.dev"
} }
@ -182,7 +182,7 @@
"Ordering": { "Ordering": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44356", "Address": "http://orderingService",
"MetaData": { "MetaData": {
"PublicAddress": "https://ordering.eshoponabp.dev" "PublicAddress": "https://ordering.eshoponabp.dev"
} }
@ -192,7 +192,7 @@
"CmsKit": { "CmsKit": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44358", "Address": "http://cmsKitService",
"MetaData": { "MetaData": {
"PublicAddress": "https://cmskit.eshoponabp.dev" "PublicAddress": "https://cmskit.eshoponabp.dev"
} }
@ -202,7 +202,7 @@
"Payment": { "Payment": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44357", "Address": "http://paymentService",
"MetaData": { "MetaData": {
"PublicAddress": "https://payment.eshoponabp.dev" "PublicAddress": "https://payment.eshoponabp.dev"
} }

11
services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs

@ -156,11 +156,12 @@ public class BasketServiceModule : AbpModule
{ {
context.Services.AddGrpcClient<ProductPublic.ProductPublicClient>((services, options) => context.Services.AddGrpcClient<ProductPublic.ProductPublicClient>((services, options) =>
{ {
var remoteServiceOptions = services.GetRequiredService<IOptionsMonitor<AbpRemoteServiceOptions>>().CurrentValue; options.Address = new Uri("http://catalogService");
var catalogServiceConfiguration = remoteServiceOptions.RemoteServices.GetConfigurationOrDefault("Catalog"); // var remoteServiceOptions = services.GetRequiredService<IOptionsMonitor<AbpRemoteServiceOptions>>().CurrentValue;
var catalogGrpcUrl = catalogServiceConfiguration.GetOrDefault("GrpcUrl"); // var catalogServiceConfiguration = remoteServiceOptions.RemoteServices.GetConfigurationOrDefault("Catalog");
// var catalogGrpcUrl = catalogServiceConfiguration.GetOrDefault("GrpcUrl");
if (catalogGrpcUrl != null) options.Address = new Uri(catalogGrpcUrl); //
// if (catalogGrpcUrl != null) options.Address = new Uri(catalogGrpcUrl);
}); });
} }

6
shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj

@ -7,12 +7,16 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Serilog.AspNetCore" Version="5.0.0" /> <PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="8.0.0" /> <PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="8.0.0" />
<PackageReference Include="Volo.Abp.Swashbuckle" Version="8.0.0" /> <PackageReference Include="Volo.Abp.Swashbuckle" Version="8.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\aspire\ServiceDefaults\eShopOnAbp.ServiceDefaults.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EShopOnAbp.Shared.Hosting\EShopOnAbp.Shared.Hosting.csproj" /> <ProjectReference Include="..\EShopOnAbp.Shared.Hosting\EShopOnAbp.Shared.Hosting.csproj" />
<ProjectReference Include="..\EShopOnAbp.Shared.Localization\EShopOnAbp.Shared.Localization.csproj" /> <ProjectReference Include="..\EShopOnAbp.Shared.Localization\EShopOnAbp.Shared.Localization.csproj" />
</ItemGroup> </ItemGroup>

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

@ -8,6 +8,9 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Yarp.ReverseProxy" Version="2.1.0" /> <PackageReference Include="Yarp.ReverseProxy" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery.Yarp" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery.Dns" Version="8.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

13
shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbpSharedHostingGatewaysModule.cs

@ -12,9 +12,20 @@ namespace EShopOnAbp.Shared.Hosting.Gateways
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
var configuration = context.Services.GetConfiguration(); var configuration = context.Services.GetConfiguration();
context.Services.AddServiceDiscovery();
context.Services.ConfigureHttpClientDefaults(http =>
{
// Turn on resilience by default
http.AddStandardResilienceHandler();
// Turn on service discovery by default
http.AddServiceDiscovery();
});
context.Services.AddReverseProxy() context.Services.AddReverseProxy()
.LoadFromConfig(configuration.GetSection("ReverseProxy")); .LoadFromConfig(configuration.GetSection("ReverseProxy"))
.AddServiceDiscoveryDestinationResolver();
} }
} }
} }
Loading…
Cancel
Save