From 147399f5472e57c34a53cc28226cbd0542b25081 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 15 Jan 2021 13:23:46 +0300 Subject: [PATCH] [#312] cmd/node: Implement HealthStatus method on node application Signed-off-by: Leonard Lyubich --- cmd/neofs-node/config.go | 5 ++++- cmd/neofs-node/control.go | 12 ++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 850a8b6fc..2f02babec 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -184,6 +184,8 @@ type cfg struct { cfgControlService cfgControlService + netStatus *atomic.Int32 + healthStatus *atomic.Int32 } @@ -342,7 +344,8 @@ func initCfg(path string) *cfg { cfgObject: cfgObject{ pool: initObjectPool(viperCfg), }, - healthStatus: atomic.NewInt32(int32(control.NetmapStatus_STATUS_UNDEFINED)), + netStatus: atomic.NewInt32(int32(control.NetmapStatus_STATUS_UNDEFINED)), + healthStatus: atomic.NewInt32(int32(control.HealthStatus_HEALTH_STATUS_UNDEFINED)), } initLocalStorage(c) diff --git a/cmd/neofs-node/control.go b/cmd/neofs-node/control.go index ed9572cc3..0b09ff8e4 100644 --- a/cmd/neofs-node/control.go +++ b/cmd/neofs-node/control.go @@ -69,9 +69,17 @@ func initControlService(c *cfg) { } func (c *cfg) setNetmapStatus(st control.NetmapStatus) { - c.healthStatus.Store(int32(st)) + c.netStatus.Store(int32(st)) } func (c *cfg) NetmapStatus() control.NetmapStatus { - return control.NetmapStatus(c.healthStatus.Load()) + return control.NetmapStatus(c.netStatus.Load()) +} + +func (c *cfg) setHealthStatus(st control.HealthStatus) { + c.healthStatus.Store(int32(st)) +} + +func (c *cfg) HealthStatus() control.HealthStatus { + return control.HealthStatus(c.healthStatus.Load()) }