frostfs-node/pkg/services/control/server/get_netmap_status.go
Dmitrii Stepanov a83eeddb1d [#60] control: Add GetNetmapStatus method
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2024-06-20 16:28:42 +03:00

35 lines
918 B
Go

package control
import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/server/ctrlmessage"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// GetNetmapStatus gets node status in FrostFS network.
func (s *Server) GetNetmapStatus(_ context.Context, req *control.GetNetmapStatusRequest) (*control.GetNetmapStatusResponse, error) {
if err := s.isValidRequest(req); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
st, epoch, err := s.nodeState.GetNetmapStatus()
if err != nil {
return nil, err
}
resp := &control.GetNetmapStatusResponse{
Body: &control.GetNetmapStatusResponse_Body{
Status: st,
Epoch: epoch,
},
}
if err := ctrlmessage.Sign(s.key, resp); err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
return resp, nil
}