-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
VirtoCommerce.Storefront/Infrastructure/HealthCheck/PlatformConnectionHealthChecker.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Diagnostics.HealthChecks; | ||
using VirtoCommerce.Storefront.Model.Stores; | ||
|
||
namespace VirtoCommerce.Storefront.Infrastructure.HealthCheck | ||
{ | ||
public class PlatformConnectionHealthChecker : IHealthCheck | ||
{ | ||
private readonly IStoreService _storeService; | ||
|
||
public PlatformConnectionHealthChecker(IStoreService storeService) | ||
{ | ||
_storeService = storeService; | ||
} | ||
|
||
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) | ||
{ | ||
try | ||
{ | ||
await _storeService.GetAllStoresAsync(); | ||
return HealthCheckResult.Healthy("Connection to the Platform is OK"); | ||
} | ||
catch | ||
{ | ||
return HealthCheckResult.Unhealthy("Connection to the Platform fails"); | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters