2021-01-13 12:49:46 +00:00
|
|
|
package private
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/services/private"
|
|
|
|
"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 *private.HealthCheckRequest) (*private.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(private.HealthCheckResponse)
|
|
|
|
|
|
|
|
body := new(private.HealthCheckResponse_Body)
|
|
|
|
resp.SetBody(body)
|
|
|
|
|
2021-01-13 13:34:59 +00:00
|
|
|
body.SetStatus(s.healthChecker.HealthStatus())
|
2021-01-13 12:49:46 +00:00
|
|
|
|
|
|
|
// sign the response
|
|
|
|
if err := SignMessage(s.key, resp); err != nil {
|
|
|
|
return nil, status.Error(codes.Internal, err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp, nil
|
|
|
|
}
|