Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow health services to be omitted. #138

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rest/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type HealthResponse struct {
// Note that the individual HealthResults evaluated by the HealthCheck interface may again consist of a plurality services. While this is only optional it allows for creating nested health structures. These can be used for more sophisticated scenarios like evaluating platform health describing service availability in different locations or similar.
//
// If using nested HealthResults, the status of the parent service can be derived automatically from the status of its children by leaving the parent's health status field blank.
Services map[string]HealthResult `json:"services"`
Services map[string]HealthResult `json:"services,omitempty"`
}

// HealthResult holds the health state of a service.
Expand Down
30 changes: 12 additions & 18 deletions rest/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ func (e *succeedingCheck) Check(ctx context.Context) (HealthResult, error) {
Message: "",
Services: map[string]HealthResult{
"successPartition": {
Status: HealthStatusHealthy,
Message: "",
Services: map[string]HealthResult{},
Status: HealthStatusHealthy,
Message: "",
},
},
}, nil
Expand All @@ -43,9 +42,8 @@ func (e *failingCheck) Check(ctx context.Context) (HealthResult, error) {
Message: "",
Services: map[string]HealthResult{
"failPartition": {
Status: HealthStatusUnhealthy,
Message: "facing an issue",
Services: map[string]HealthResult{},
Status: HealthStatusUnhealthy,
Message: "facing an issue",
},
},
}, fmt.Errorf("facing an issue")
Expand Down Expand Up @@ -73,9 +71,8 @@ func TestNewHealth(t *testing.T) {
h: nil,
},
want: &HealthResponse{
Status: HealthStatusHealthy,
Message: "",
Services: map[string]HealthResult{},
Status: HealthStatusHealthy,
Message: "",
},
},
{
Expand All @@ -94,9 +91,8 @@ func TestNewHealth(t *testing.T) {
Message: "",
Services: map[string]HealthResult{
"successPartition": {
Status: HealthStatusHealthy,
Message: "",
Services: map[string]HealthResult{},
Status: HealthStatusHealthy,
Message: "",
},
},
},
Expand All @@ -105,9 +101,8 @@ func TestNewHealth(t *testing.T) {
Message: "facing an issue",
Services: map[string]HealthResult{
"failPartition": {
Status: HealthStatusUnhealthy,
Message: "facing an issue",
Services: map[string]HealthResult{},
Status: HealthStatusUnhealthy,
Message: "facing an issue",
},
},
},
Expand All @@ -131,9 +126,8 @@ func TestNewHealth(t *testing.T) {
Message: "",
Services: map[string]HealthResult{
"successPartition": {
Status: HealthStatusHealthy,
Message: "",
Services: map[string]HealthResult{},
Status: HealthStatusHealthy,
Message: "",
},
},
},
Expand Down
Loading