frostfs-node/pkg/network/transport/object/grpc/implementations.go

33 lines
737 B
Go
Raw Normal View History

package object
import (
"context"
"github.com/multiformats/go-multiaddr"
"github.com/nspcc-dev/neofs-api-go/object"
2020-07-24 13:54:03 +00:00
"github.com/nspcc-dev/neofs-node/pkg/network/peers"
"github.com/pkg/errors"
)
type (
remoteService struct {
ps peers.Interface
}
)
// NewRemoteService is a remote service controller's constructor.
func NewRemoteService(ps peers.Interface) RemoteService {
return &remoteService{
ps: ps,
}
}
func (rs remoteService) Remote(ctx context.Context, addr multiaddr.Multiaddr) (object.ServiceClient, error) {
2020-07-24 13:54:03 +00:00
con, err := rs.ps.GRPCConnection(ctx, addr)
if err != nil {
return nil, errors.Wrapf(err, "remoteService.Remote failed on GRPCConnection to %s", addr)
}
return object.NewServiceClient(con), nil
}