Skip to content

Commit

Permalink
fix health check for ps API (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
cfarmer-fearless authored Mar 5, 2024
1 parent b5530b6 commit 0f34455
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
using System.Text.Json.Serialization;

namespace BulkFileUploadFunctionApp.Model
{
public class HealthCheckResponse
public record HealthCheckResponse
{
public string Status { get; set; }
[JsonPropertyName("status")]
public string Status { get; set; }
[JsonPropertyName("total_checks_duration")]
public string TotalChecksDuration { get; set; } // Duration of all health checks combined.
[JsonPropertyName("dependency_health_checks")]
public List<HealthCheckResult> DependencyHealthChecks { get; set; } = new(); // Results of individual dependency health checks.

public HealthCheckResult ToHealthCheckResult(string serviceName)
{
HealthCheckResult result = new HealthCheckResult(serviceName, Status);
List<string> healthIssuesList = DependencyHealthChecks
.Select(check => check.HealthIssues)
.Where(issue => !string.IsNullOrEmpty(issue))
.ToList();

// Aggregate health issues from dependent health checks.
string healthIssues = string.Join(",", DependencyHealthChecks.Select(check => check.HealthIssues));
string healthIssues = string.Join(",", healthIssuesList);
result.HealthIssues = healthIssues;

return result;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@

using System.Text.Json.Serialization;

namespace BulkFileUploadFunctionApp.Model
{
public class HealthCheckResult
public record HealthCheckResult
{
[JsonPropertyName("service")]
public string Service { get; set; }
[JsonPropertyName("status")]
public string Status { get; set; }
[JsonPropertyName("health_issues")]
public string HealthIssues { get; set; }

// Constructor for easily setting properties upon creation
Expand Down

0 comments on commit 0f34455

Please sign in to comment.