2021-06-09 15:37:03 +00:00
|
|
|
package control
|
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/common"
|
2023-04-25 12:09:20 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/grpc"
|
2021-06-09 15:37:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const serviceName = "ircontrol.ControlService"
|
|
|
|
|
|
|
|
const (
|
2023-10-16 15:15:04 +00:00
|
|
|
rpcHealthCheck = "HealthCheck"
|
|
|
|
rpcTickEpoch = "TickEpoch"
|
|
|
|
rpcRemoveNode = "RemoveNode"
|
|
|
|
rpcRemoveContainer = "RemoveContainer"
|
2021-06-09 15:37:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// HealthCheck executes ControlService.HealthCheck RPC.
|
|
|
|
func HealthCheck(
|
|
|
|
cli *client.Client,
|
|
|
|
req *HealthCheckRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*HealthCheckResponse, error) {
|
2023-04-25 12:09:20 +00:00
|
|
|
return sendUnary[HealthCheckRequest, HealthCheckResponse](cli, rpcHealthCheck, req, opts...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TickEpoch executes ControlService.TickEpoch RPC.
|
|
|
|
func TickEpoch(
|
|
|
|
cli *client.Client,
|
|
|
|
req *TickEpochRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*TickEpochResponse, error) {
|
|
|
|
return sendUnary[TickEpochRequest, TickEpochResponse](cli, rpcTickEpoch, req, opts...)
|
|
|
|
}
|
|
|
|
|
2023-05-03 13:19:46 +00:00
|
|
|
func RemoveNode(
|
|
|
|
cli *client.Client,
|
|
|
|
req *RemoveNodeRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*RemoveNodeResponse, error) {
|
|
|
|
return sendUnary[RemoveNodeRequest, RemoveNodeResponse](cli, rpcRemoveNode, req, opts...)
|
|
|
|
}
|
|
|
|
|
2023-10-16 15:15:04 +00:00
|
|
|
func RemoveContainer(
|
|
|
|
cli *client.Client,
|
|
|
|
req *RemoveContainerRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*RemoveContainerResponse, error) {
|
|
|
|
return sendUnary[RemoveContainerRequest, RemoveContainerResponse](cli, rpcRemoveContainer, req, opts...)
|
|
|
|
}
|
|
|
|
|
2023-04-25 12:09:20 +00:00
|
|
|
func sendUnary[I, O grpc.Message](cli *client.Client, rpcName string, req *I, opts ...client.CallOption) (*O, error) {
|
|
|
|
var resp O
|
|
|
|
wResp := &responseWrapper[*O]{
|
|
|
|
m: &resp,
|
2021-06-09 15:37:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wReq := &requestWrapper{
|
|
|
|
m: req,
|
|
|
|
}
|
|
|
|
|
2023-04-25 12:09:20 +00:00
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcName), wReq, wResp, opts...)
|
2021-06-09 15:37:03 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.m, nil
|
|
|
|
}
|