frostfs-node/pkg/services/control/server/healthcheck.go
Alex Vanin 20de74a505 Rename package name
Due to source code relocation from GitHub.

Signed-off-by: Alex Vanin <a.vanin@yadro.com>
2023-03-07 16:38:26 +03:00

35 lines
969 B
Go

package control
import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// HealthCheck returns health status of the local node.
//
// If request is unsigned or signed by disallowed key, permission error returns.
func (s *Server) HealthCheck(_ context.Context, req *control.HealthCheckRequest) (*control.HealthCheckResponse, error) {
// verify request
if err := s.isValidRequest(req); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
// create and fill response
resp := new(control.HealthCheckResponse)
body := new(control.HealthCheckResponse_Body)
resp.SetBody(body)
body.SetNetmapStatus(s.healthChecker.NetmapStatus())
body.SetHealthStatus(s.healthChecker.HealthStatus())
// sign the response
if err := SignMessage(s.key, resp); err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
return resp, nil
}