frostfs-s3-gw/api/pool/v2.go
Evgeniy Kulikov b346a77933 [#25] Migrate connection pool to NeoFS API v2
closes #25

Signed-off-by: Evgeniy Kulikov <kim@nspcc.ru>
2020-10-13 12:32:23 +03:00

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
}