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

Commit 926cc9f

Browse files
Igor SychevIgor Sychev
authored andcommitted
Health check for Payment
1 parent 202e663 commit 926cc9f

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

docker-compose.override.yml

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

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: 7 additions & 0 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
{
@@ -70,6 +72,11 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
7072
});
7173
}
7274

75+
services.AddHealthChecks(checks =>
76+
{
77+
checks.AddValueTaskCheck("HTTP Endpoint", () => new ValueTask<IHealthCheckResult>(HealthCheckResult.Healthy("Ok")));
78+
});
79+
7380
RegisterEventBus(services);
7481

7582
services.AddSwaggerGen(options =>

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)