[#1048] control: Add ListShards RPC wrappers

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-12-17 18:23:46 +03:00 committed by Alex Vanin
parent a6b3e16975
commit f88a12eaa7
2 changed files with 41 additions and 0 deletions

View file

@ -92,3 +92,22 @@ func (w *dropObjectsResponseWrapper) FromGRPCMessage(m grpc.Message) error {
return nil
}
type listShardsRequestWrapper struct {
m *ListShardsResponse
}
func (w *listShardsRequestWrapper) ToGRPCMessage() grpc.Message {
return w.m
}
func (w *listShardsRequestWrapper) FromGRPCMessage(m grpc.Message) error {
var ok bool
w.m, ok = m.(*ListShardsResponse)
if !ok {
return message.NewUnexpectedMessageType(m, w.m)
}
return nil
}

View file

@ -12,6 +12,7 @@ const (
rpcNetmapSnapshot = "NetmapSnapshot"
rpcSetNetmapStatus = "SetNetmapStatus"
rpcDropObjects = "DropObjects"
rpcListShards = "ListShards"
)
// HealthCheck executes ControlService.HealthCheck RPC.
@ -100,3 +101,24 @@ func DropObjects(
return wResp.m, nil
}
// ListShards executes ControlService.ListShards RPC.
func ListShards(
cli *client.Client,
req *ListShardsRequest,
opts ...client.CallOption,
) (*ListShardsResponse, error) {
wResp := &listShardsRequestWrapper{
m: new(ListShardsResponse),
}
wReq := &requestWrapper{
m: req,
}
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcListShards), wReq, wResp, opts...)
if err != nil {
return nil, err
}
return wResp.m, nil
}