2021-03-12 12:57:23 +00:00
|
|
|
package rpc
|
|
|
|
|
|
|
|
import (
|
2023-03-07 10:38:56 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/netmap"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/common"
|
2021-03-12 12:57:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const serviceNetmap = serviceNamePrefix + "netmap.NetmapService"
|
|
|
|
|
|
|
|
const (
|
|
|
|
rpcNetmapNodeInfo = "LocalNodeInfo"
|
|
|
|
rpcNetmapNetInfo = "NetworkInfo"
|
2022-09-17 09:59:54 +00:00
|
|
|
rpcNetmapSnapshot = "NetmapSnapshot"
|
2021-03-12 12:57:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// LocalNodeInfo executes NetmapService.LocalNodeInfo RPC.
|
|
|
|
func LocalNodeInfo(
|
|
|
|
cli *client.Client,
|
|
|
|
req *netmap.LocalNodeInfoRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*netmap.LocalNodeInfoResponse, error) {
|
|
|
|
resp := new(netmap.LocalNodeInfoResponse)
|
|
|
|
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceNetmap, rpcNetmapNodeInfo), req, resp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkInfo executes NetmapService.NetworkInfo RPC.
|
|
|
|
func NetworkInfo(
|
|
|
|
cli *client.Client,
|
|
|
|
req *netmap.NetworkInfoRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*netmap.NetworkInfoResponse, error) {
|
|
|
|
resp := new(netmap.NetworkInfoResponse)
|
|
|
|
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceNetmap, rpcNetmapNetInfo), req, resp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp, nil
|
|
|
|
}
|
2022-09-17 09:59:54 +00:00
|
|
|
|
|
|
|
// NetMapSnapshot executes NetmapService.NetmapSnapshot RPC.
|
|
|
|
func NetMapSnapshot(
|
|
|
|
cli *client.Client,
|
|
|
|
req *netmap.SnapshotRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*netmap.SnapshotResponse, error) {
|
|
|
|
resp := new(netmap.SnapshotResponse)
|
|
|
|
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceNetmap, rpcNetmapSnapshot), req, resp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp, nil
|
|
|
|
}
|