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 launchProfile = "HTTP";
// Microservices
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 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")
.WithReference(catalogService); //?
var cmsKitService = builder.AddProject<Projects.EShopOnAbp_CmskitService_HttpApi_Host>("cmsKitService");
@ -13,9 +15,17 @@ var paymentService = builder.AddProject<Projects.EShopOnAbp_PaymentService_HttpA
// Gateways
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
var publicWebApp = builder.AddProject<Projects.EShopOnAbp_PublicWeb>("public-web");
var publicWebApp = builder.AddProject<Projects.EShopOnAbp_PublicWeb>("public-web")
.WithExternalHttpEndpoints();
builder.Build().Run();

4
aspire/ServiceDefaults/eShopOnAbp.ServiceDefaults.csproj

@ -10,8 +10,8 @@
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.3.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.0-preview.7.24251.11" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.5.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" 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": {
"Destinations": {
"destination1": {
"Address": "https://localhost:44351",
"Address": "http://identityService",
"MetaData": {
"PublicAddress": "https://identity.eshoponabp.dev"
}
@ -152,7 +152,7 @@
"Administration": {
"Destinations": {
"destination1": {
"Address": "https://localhost:44353",
"Address": "http://admininstrationService",
"MetaData": {
"PublicAddress": "https://admininstration.eshop.dev"
}
@ -162,9 +162,9 @@
"catalogCluster": {
"Destinations": {
"destination1": {
"Address": "https://localhost:44354",
"Address": "http://catalogService",
"MetaData": {
"PublicAddress": "https://admininstration.eshoponabp.dev"
"PublicAddress": "https://catalog.eshoponabp.dev"
}
}
}
@ -172,7 +172,7 @@
"Basket": {
"Destinations": {
"destination1": {
"Address": "https://localhost:44355",
"Address": "http://basketService",
"MetaData": {
"PublicAddress": "https://basket.eshoponabp.dev"
}
@ -182,7 +182,7 @@
"Ordering": {
"Destinations": {
"destination1": {
"Address": "https://localhost:44356",
"Address": "http://orderingService",
"MetaData": {
"PublicAddress": "https://ordering.eshoponabp.dev"
}
@ -192,7 +192,7 @@
"CmsKit": {
"Destinations": {
"destination1": {
"Address": "https://localhost:44358",
"Address": "http://cmsKitService",
"MetaData": {
"PublicAddress": "https://cmskit.eshoponabp.dev"
}
@ -202,7 +202,7 @@
"Payment": {
"Destinations": {
"destination1": {
"Address": "https://localhost:44357",
"Address": "http://paymentService",
"MetaData": {
"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) =>
{
var remoteServiceOptions = services.GetRequiredService<IOptionsMonitor<AbpRemoteServiceOptions>>().CurrentValue;
var catalogServiceConfiguration = remoteServiceOptions.RemoteServices.GetConfigurationOrDefault("Catalog");
var catalogGrpcUrl = catalogServiceConfiguration.GetOrDefault("GrpcUrl");
if (catalogGrpcUrl != null) options.Address = new Uri(catalogGrpcUrl);
options.Address = new Uri("http://catalogService");
// var remoteServiceOptions = services.GetRequiredService<IOptionsMonitor<AbpRemoteServiceOptions>>().CurrentValue;
// var catalogServiceConfiguration = remoteServiceOptions.RemoteServices.GetConfigurationOrDefault("Catalog");
// var catalogGrpcUrl = catalogServiceConfiguration.GetOrDefault("GrpcUrl");
//
// if (catalogGrpcUrl != null) options.Address = new Uri(catalogGrpcUrl);
});
}

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

@ -7,12 +7,16 @@
</PropertyGroup>
<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.Swashbuckle" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\aspire\ServiceDefaults\eShopOnAbp.ServiceDefaults.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EShopOnAbp.Shared.Hosting\EShopOnAbp.Shared.Hosting.csproj" />
<ProjectReference Include="..\EShopOnAbp.Shared.Localization\EShopOnAbp.Shared.Localization.csproj" />
</ItemGroup>

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

@ -8,6 +8,9 @@
<ItemGroup>
<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>

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

@ -12,9 +12,20 @@ namespace EShopOnAbp.Shared.Hosting.Gateways
public override void ConfigureServices(ServiceConfigurationContext context)
{
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()
.LoadFromConfig(configuration.GetSection("ReverseProxy"));
.LoadFromConfig(configuration.GetSection("ReverseProxy"))
.AddServiceDiscoveryDestinationResolver();
}
}
}
Loading…
Cancel
Save