From b4852038a1dc453229395baa96d4889700d816be Mon Sep 17 00:00:00 2001 From: Cory Schwartz Date: Mon, 23 May 2022 11:11:45 -0700 Subject: [PATCH] Update node/health.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ɓukasz Magiera --- node/health.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/node/health.go b/node/health.go index a92997a61..9e9f3bb80 100644 --- a/node/health.go +++ b/node/health.go @@ -10,15 +10,19 @@ import ( ) type HealthHandler struct { - healthy bool + healthy int32 } func (h *HealthHandler) SetHealthy(healthy bool) { - h.healthy = healthy + h := int32(0) + if healthy { + h = 1 + } + atomic.StoreInt32(&h.healthy, h) } func (h *HealthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - if !h.healthy { + if atomic.LoadInt32(&h.healthy) != 1 { w.WriteHeader(http.StatusServiceUnavailable) return }