[#312] control: Add health status field to health check response body

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-01-15 13:18:03 +03:00 committed by Alex Vanin
parent 0abb8acef3
commit 6ae51e41f9
4 changed files with 28 additions and 2 deletions

View file

@ -66,9 +66,17 @@ func (x *HealthCheckResponse_Body) SetNetmapStatus(v NetmapStatus) {
}
}
// SetHealthStatus sets health status of the storage node application.
func (x *HealthCheckResponse_Body) SetHealthStatus(v HealthStatus) {
if x != nil {
x.HealthStatus = v
}
}
const (
_ = iota
healthRespBodyStatusFNum
healthRespBodyHealthStatusFNum
)
// StableMarshal reads binary representation of health check response body
@ -89,7 +97,19 @@ func (x *HealthCheckResponse_Body) StableMarshal(buf []byte) ([]byte, error) {
buf = make([]byte, sz)
}
_, err := proto.EnumMarshal(healthRespBodyStatusFNum, buf, int32(x.NetmapStatus))
var (
offset, n int
err error
)
n, err = proto.EnumMarshal(healthRespBodyStatusFNum, buf[offset:], int32(x.NetmapStatus))
if err != nil {
return nil, err
}
offset += n
_, err = proto.EnumMarshal(healthRespBodyHealthStatusFNum, buf[offset:], int32(x.HealthStatus))
if err != nil {
return nil, err
}
@ -109,6 +129,7 @@ func (x *HealthCheckResponse_Body) StableSize() int {
size := 0
size += proto.EnumSize(healthRespBodyStatusFNum, int32(x.NetmapStatus))
size += proto.EnumSize(healthRespBodyHealthStatusFNum, int32(x.HealthStatus))
return size
}

Binary file not shown.

View file

@ -34,6 +34,9 @@ message HealthCheckResponse {
message Body {
// Status of the storage node in NeoFS network map.
NetmapStatus netmap_status = 1;
// Health status of storage node application.
HealthStatus health_status = 2;
}
// Body of health check response message.

View file

@ -22,12 +22,14 @@ func TestHealthCheckResponse_Body_StableMarshal(t *testing.T) {
func generateHealthCheckResponseBody() *control.HealthCheckResponse_Body {
body := new(control.HealthCheckResponse_Body)
body.SetNetmapStatus(control.NetmapStatus_ONLINE)
body.SetHealthStatus(control.HealthStatus_SHUTTING_DOWN)
return body
}
func equalHealthCheckResponseBodies(b1, b2 *control.HealthCheckResponse_Body) bool {
return b1.GetNetmapStatus() == b2.GetNetmapStatus()
return b1.GetNetmapStatus() == b2.GetNetmapStatus() &&
b1.GetHealthStatus() == b2.GetHealthStatus()
}
func TestNetmapSnapshotResponse_Body_StableMarshal(t *testing.T) {