frostfs-api-go/rpc/netmap.go
Evgenii Stratonikov 3a1a6c72f3
Some checks failed
Tests and linters / Tests (1.19) (pull_request) Successful in 33s
Tests and linters / Lint (pull_request) Failing after 39s
DCO action / DCO (pull_request) Failing after 45s
Tests and linters / Tests (1.20) (pull_request) Successful in 52s
Tests and linters / Tests with -race (pull_request) Successful in 1m5s
protogen: Initial implementation
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2024-08-08 15:46:56 +03:00

62 lines
1.6 KiB
Go

package rpc
import (
"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"
)
const serviceNetmap = serviceNamePrefix + "netmap.NetmapService"
const (
rpcNetmapNodeInfo = "LocalNodeInfo"
rpcNetmapNetInfo = "NetworkInfo"
rpcNetmapSnapshot = "NetmapSnapshot"
)
// 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
}
// 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
}