Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 79d045f

Browse files
Merge pull request #320 from SychevIgor/SychevIgor/PaymntHealthCheck
payment API require health check
2 parents ed0ca3e + f9c7e38 commit 79d045f

File tree

7 files changed

+11
-46
lines changed

7 files changed

+11
-46
lines changed

docker-compose.override.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ services:
136136
- IdentityUrl=http://identity.api/hc
137137
- LocationsUrl=http://locations.api/hc
138138
- MarketingUrl=http://marketing.api/hc
139+
- PaymentUrl=http://payment.api/hc
139140
- mvc=http://webmvc/hc
140141
- spa=http://webspa/hc
141142
ports:

src/Services/Payment/Payment.API/Controllers/HomeController.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Services/Payment/Payment.API/Payment.API.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@
66
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
77
</PropertyGroup>
88

9-
<ItemGroup>
10-
<Folder Include="wwwroot\" />
11-
</ItemGroup>
129
<ItemGroup>
1310
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" />
1411
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
15-
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
1612
</ItemGroup>
1713
<ItemGroup>
1814
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />

src/Services/Payment/Payment.API/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static void Main(string[] args)
1515

1616
public static IWebHost BuildWebHost(string[] args) =>
1717
WebHost.CreateDefaultBuilder(args)
18-
18+
.UseHealthChecks("/hc")
1919
.UseContentRoot(Directory.GetCurrentDirectory())
2020
.UseStartup<Startup>()
2121
.ConfigureLogging((hostingContext, builder) =>

src/Services/Payment/Payment.API/Startup.cs

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
1010
using Microsoft.Extensions.Configuration;
1111
using Microsoft.Extensions.DependencyInjection;
12+
using Microsoft.Extensions.HealthChecks;
1213
using Microsoft.Extensions.Logging;
1314
using Payment.API.IntegrationEvents.EventHandling;
1415
using Payment.API.IntegrationEvents.Events;
1516
using RabbitMQ.Client;
1617
using System;
18+
using System.Threading.Tasks;
1719

1820
namespace Payment.API
1921
{
@@ -29,8 +31,6 @@ public Startup(IConfiguration configuration)
2931
// This method gets called by the runtime. Use this method to add services to the container.
3032
public IServiceProvider ConfigureServices(IServiceCollection services)
3133
{
32-
// Add framework services.
33-
services.AddMvc();
3434

3535
services.Configure<PaymentSettings>(Configuration);
3636

@@ -70,20 +70,13 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
7070
});
7171
}
7272

73-
RegisterEventBus(services);
74-
75-
services.AddSwaggerGen(options =>
73+
services.AddHealthChecks(checks =>
7674
{
77-
options.DescribeAllEnumsAsStrings();
78-
options.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info
79-
{
80-
Title = "eShopOnContainers - Payment HTTP API",
81-
Version = "v1",
82-
Description = "The Payment Microservice HTTP API. This is a Data-Driven/CRUD microservice sample",
83-
TermsOfService = "Terms Of Service"
84-
});
75+
checks.AddValueTaskCheck("HTTP Endpoint", () => new ValueTask<IHealthCheckResult>(HealthCheckResult.Healthy("Ok")));
8576
});
8677

78+
RegisterEventBus(services);
79+
8780
var container = new ContainerBuilder();
8881
container.Populate(services);
8982
return new AutofacServiceProvider(container.Build());
@@ -98,14 +91,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
9891
app.UsePathBase(pathBase);
9992
}
10093

101-
app.UseMvcWithDefaultRoute();
102-
103-
app.UseSwagger()
104-
.UseSwaggerUI(c =>
105-
{
106-
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
107-
});
108-
10994
ConfigureEventBus(app);
11095
}
11196

src/Web/WebStatus/Startup.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public void ConfigureServices(IServiceCollection services)
4040
checks.AddUrlCheckIfNotNull(Configuration["IdentityUrl"], TimeSpan.FromMinutes(minutes));
4141
checks.AddUrlCheckIfNotNull(Configuration["LocationsUrl"], TimeSpan.FromMinutes(minutes));
4242
checks.AddUrlCheckIfNotNull(Configuration["MarketingUrl"], TimeSpan.FromMinutes(minutes));
43+
checks.AddUrlCheckIfNotNull(Configuration["PaymentUrl"], TimeSpan.FromMinutes(minutes));
4344
checks.AddUrlCheckIfNotNull(Configuration["mvc"], TimeSpan.FromMinutes(minutes));
4445
checks.AddUrlCheckIfNotNull(Configuration["spa"], TimeSpan.FromMinutes(minutes));
4546
});

src/Web/WebStatus/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
"CatalogUrl": "http://localhost:5101/hc",
1111
"IdentityUrl": "http://localhost:5105/hc",
1212
"MarketingUrl": "http://localhost:5110/hc",
13-
"LocationsUrl": "http://localhost:5109/hc"
13+
"LocationsUrl": "http://localhost:5109/hc",
14+
"PaymentUrl": "http://localhost:5108/hc"
1415
}

0 commit comments

Comments
 (0)