From 5c97608ccc7565ce1af9101cf787ac0eb1baac45 Mon Sep 17 00:00:00 2001 From: Dimitar Petrov Date: Tue, 25 Jun 2019 12:51:29 +0300 Subject: [PATCH 1/2] Omit empty fields of State struct --- health.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/health.go b/health.go index f542236..7aed09a 100644 --- a/health.go +++ b/health.go @@ -92,7 +92,7 @@ type Config struct { // run of a particular check. type State struct { // Name of the health check - Name string `json:"name"` + Name string `json:"name,omitempty"` // Status of the health check state ("ok" or "failed") Status string `json:"status"` @@ -108,10 +108,10 @@ type State struct { Details interface{} `json:"details,omitempty"` // contains JSON message (that can be marshaled) // CheckTime is the time of the last health check - CheckTime time.Time `json:"check_time"` + CheckTime time.Time `json:"check_time,omitempty"` - ContiguousFailures int64 `json:"num_failures"` // the number of failures that occurred in a row - TimeOfFirstFailure time.Time `json:"first_failure_at"` // the time of the initial transitional failure for any given health check + ContiguousFailures int64 `json:"num_failures,omitempty"` // the number of failures that occurred in a row + TimeOfFirstFailure time.Time `json:"first_failure_at,omitempty"` // the time of the initial transitional failure for any given health check } // indicates state is failure From 760aa2792a3bb83cc64ed4a7720283c14953bf2a Mon Sep 17 00:00:00 2001 From: Dimitar Petrov Date: Wed, 26 Jun 2019 12:39:46 +0300 Subject: [PATCH 2/2] Fatal field not omitted --- health.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/health.go b/health.go index 7aed09a..a908634 100644 --- a/health.go +++ b/health.go @@ -101,7 +101,7 @@ type State struct { Err string `json:"error,omitempty"` // Fatal shows if the check will affect global result - Fatal bool `json:"fatal,omitempty"` + Fatal bool `json:"fatal"` // Details contains more contextual detail about a // failing health check.