2021-03-15 11:04:13 +00:00
|
|
|
package control
|
|
|
|
|
|
|
|
import (
|
2021-11-06 11:13:04 +00:00
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/rpc/common"
|
2021-03-15 11:04:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const serviceName = "control.ControlService"
|
|
|
|
|
|
|
|
const (
|
|
|
|
rpcHealthCheck = "HealthCheck"
|
|
|
|
rpcNetmapSnapshot = "NetmapSnapshot"
|
|
|
|
rpcSetNetmapStatus = "SetNetmapStatus"
|
|
|
|
rpcDropObjects = "DropObjects"
|
2021-12-17 15:23:46 +00:00
|
|
|
rpcListShards = "ListShards"
|
2021-12-27 16:12:23 +00:00
|
|
|
rpcSetShardMode = "SetShardMode"
|
2021-03-15 11:04:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// HealthCheck executes ControlService.HealthCheck RPC.
|
|
|
|
func HealthCheck(
|
|
|
|
cli *client.Client,
|
|
|
|
req *HealthCheckRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*HealthCheckResponse, error) {
|
|
|
|
wResp := &healthCheckResponseWrapper{
|
|
|
|
m: new(HealthCheckResponse),
|
|
|
|
}
|
|
|
|
|
|
|
|
wReq := &requestWrapper{
|
|
|
|
m: req,
|
|
|
|
}
|
|
|
|
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcHealthCheck), wReq, wResp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.m, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetmapSnapshot executes ControlService.NetmapSnapshot RPC.
|
|
|
|
func NetmapSnapshot(
|
|
|
|
cli *client.Client,
|
|
|
|
req *NetmapSnapshotRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*NetmapSnapshotResponse, error) {
|
|
|
|
wResp := &netmapSnapshotResponseWrapper{
|
|
|
|
m: new(NetmapSnapshotResponse),
|
|
|
|
}
|
|
|
|
|
|
|
|
wReq := &requestWrapper{
|
|
|
|
m: req,
|
|
|
|
}
|
|
|
|
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcNetmapSnapshot), wReq, wResp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.m, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNetmapStatus executes ControlService.SetNetmapStatus RPC.
|
|
|
|
func SetNetmapStatus(
|
|
|
|
cli *client.Client,
|
|
|
|
req *SetNetmapStatusRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*SetNetmapStatusResponse, error) {
|
|
|
|
wResp := &setNetmapStatusResponseWrapper{
|
|
|
|
m: new(SetNetmapStatusResponse),
|
|
|
|
}
|
|
|
|
|
|
|
|
wReq := &requestWrapper{
|
|
|
|
m: req,
|
|
|
|
}
|
|
|
|
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcSetNetmapStatus), wReq, wResp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.m, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// DropObjects executes ControlService.DropObjects RPC.
|
|
|
|
func DropObjects(
|
|
|
|
cli *client.Client,
|
|
|
|
req *DropObjectsRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*DropObjectsResponse, error) {
|
|
|
|
wResp := &dropObjectsResponseWrapper{
|
|
|
|
m: new(DropObjectsResponse),
|
|
|
|
}
|
|
|
|
|
|
|
|
wReq := &requestWrapper{
|
|
|
|
m: req,
|
|
|
|
}
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcDropObjects), wReq, wResp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.m, nil
|
|
|
|
}
|
2021-12-17 15:23:46 +00:00
|
|
|
|
|
|
|
// ListShards executes ControlService.ListShards RPC.
|
|
|
|
func ListShards(
|
|
|
|
cli *client.Client,
|
|
|
|
req *ListShardsRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*ListShardsResponse, error) {
|
2021-12-29 15:12:40 +00:00
|
|
|
wResp := &listShardsResponseWrapper{
|
2021-12-17 15:23:46 +00:00
|
|
|
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
|
|
|
|
}
|
2021-12-27 16:12:23 +00:00
|
|
|
|
|
|
|
// SetShardMode executes ControlService.SetShardMode RPC.
|
|
|
|
func SetShardMode(
|
|
|
|
cli *client.Client,
|
|
|
|
req *SetShardModeRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*SetShardModeResponse, error) {
|
|
|
|
wResp := &setShardModeResponseWrapper{
|
|
|
|
m: new(SetShardModeResponse),
|
|
|
|
}
|
|
|
|
|
|
|
|
wReq := &requestWrapper{
|
|
|
|
m: req,
|
|
|
|
}
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcSetShardMode), wReq, wResp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.m, nil
|
|
|
|
}
|