-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHealthResponse.cs
46 lines (38 loc) · 1.11 KB
/
HealthResponse.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
namespace NetPro.Checker
{
/// <summary>
/// Represents a health check response
/// </summary>
public struct HealthResponse
{
public readonly bool IsHealthy;
public readonly object Response;
private HealthResponse(bool isHealthy, object statusObject)
{
IsHealthy = isHealthy;
Response = statusObject;
}
public static HealthResponse Healthy()
{
return Healthy("OK");
}
public static HealthResponse Healthy(object response)
{
return new HealthResponse(true, response);
}
public static HealthResponse Unhealthy()
{
return Unhealthy("FAILED");
}
public static HealthResponse Unhealthy(object response)
{
return new HealthResponse(false, response);
}
public static HealthResponse Unhealthy(Exception exception)
{
var message = $"EXCEPTION: {exception.GetType().Name}, {exception.Message}";
return new HealthResponse(false, message);
}
}
}