From f88a12eaa76e38eb6bc3432ca210319d22b46a28 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Fri, 17 Dec 2021 18:23:46 +0300 Subject: [PATCH] [#1048] control: Add `ListShards` RPC wrappers Signed-off-by: Pavel Karpy --- pkg/services/control/convert.go | 19 +++++++++++++++++++ pkg/services/control/rpc.go | 22 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/pkg/services/control/convert.go b/pkg/services/control/convert.go index b8d7fc295..ea3c9e94b 100644 --- a/pkg/services/control/convert.go +++ b/pkg/services/control/convert.go @@ -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 +} diff --git a/pkg/services/control/rpc.go b/pkg/services/control/rpc.go index ef3311c0e..1fda70bf0 100644 --- a/pkg/services/control/rpc.go +++ b/pkg/services/control/rpc.go @@ -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 +}