forked from TrueCloudLab/frostfs-s3-gw
b346a77933
closes #25 Signed-off-by: Evgeniy Kulikov <kim@nspcc.ru>
36 lines
850 B
Go
36 lines
850 B
Go
package pool
|
|
|
|
import (
|
|
"context"
|
|
"crypto/ecdsa"
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/client"
|
|
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
|
"github.com/nspcc-dev/neofs-api-go/v2/signature"
|
|
"github.com/pkg/errors"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
type v2Ping struct {
|
|
req *netmap.LocalNodeInfoRequest
|
|
}
|
|
|
|
func newV2Ping(key *ecdsa.PrivateKey) (Pinger, error) {
|
|
req := new(netmap.LocalNodeInfoRequest)
|
|
|
|
if err := signature.SignServiceMessage(key, req); err != nil {
|
|
return nil, errors.Wrap(err, "could not sign `PingRequest`")
|
|
}
|
|
|
|
return &v2Ping{req: req}, nil
|
|
}
|
|
|
|
func (v *v2Ping) Call(ctx context.Context, conn *grpc.ClientConn) error {
|
|
if cli, err := netmap.NewClient(netmap.WithGlobalOpts(client.WithGRPCConn(conn))); err != nil {
|
|
return err
|
|
} else if _, err := cli.LocalNodeInfo(ctx, v.req); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|